Skip to content

Commit 1b925f1

Browse files
committed
TASK: Updating RAML types, Postman and OAS definition
1 parent 07ebd3b commit 1b925f1

File tree

12 files changed

+2369
-0
lines changed

12 files changed

+2369
-0
lines changed

bruno/checkout/.env.sample

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CTP_CLIENT_ID=
2+
CTP_CLIENT_SECRET=
3+
CTP_API_URL=https://checkout.europe-west1.gcp.commercetools.com
4+
CTP_AUTH_URL=https://auth.europe-west1.gcp.commercetools.com
5+
CTP_PROJECT_KEY=
6+
CTP_USERNAME=
7+
CTP_USER_PWD=

bruno/checkout/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
meta {
2+
name: post ByProjectKeyPaymentIntentsByPaymentId
3+
type: http
4+
seq: 4
5+
}
6+
7+
post {
8+
url: {{apiUrl}}/{{project-key}}/payment-intents/{{payment-id}}
9+
body: json
10+
auth: inherit
11+
}
12+
13+
body:json {
14+
{
15+
"actions" : [ {
16+
"action" : "capturePayment",
17+
"amount" : {
18+
"centAmount" : 10000,
19+
"currencyCode" : "EUR"
20+
},
21+
"merchantReference" : "example-reference"
22+
} ]
23+
}
24+
}
25+
26+
query {
27+
}
28+
29+
script:post-response {
30+
var data = res.body;
31+
if(res.status == 200 || res.status == 201) {
32+
if(data.results && data.results[0] && data.results[0].id && data.results[0].version){
33+
bru.setEnvVar("payment-intent-id", data.results[0].id);
34+
bru.setEnvVar("payment-intent-version", data.results[0].version);
35+
}
36+
if(data.results && data.results[0] && data.results[0].key){
37+
bru.setEnvVar("payment-intent-key", data.results[0].key);
38+
}
39+
if(data.version){
40+
bru.setEnvVar("payment-intent-version", data.version);
41+
}
42+
if(data.id){
43+
bru.setEnvVar("payment-intent-id", data.id);
44+
}
45+
if(data.key){
46+
bru.setEnvVar("payment-intent-key", data.key);
47+
}
48+
49+
}
50+
}
51+
52+
assert {
53+
res.status: in [200, 201]
54+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
meta {
2+
name: get ByProjectKeyTransactionsById
3+
type: http
4+
seq: 5
5+
}
6+
7+
get {
8+
url: {{apiUrl}}/{{project-key}}/transactions/{{id}}
9+
body: none
10+
auth: inherit
11+
}
12+
13+
14+
query {
15+
}
16+
17+
script:post-response {
18+
var data = res.body;
19+
if(res.status == 200 || res.status == 201) {
20+
if(data.results && data.results[0] && data.results[0].id && data.results[0].version){
21+
bru.setEnvVar("transaction-id", data.results[0].id);
22+
bru.setEnvVar("transaction-version", data.results[0].version);
23+
}
24+
if(data.results && data.results[0] && data.results[0].key){
25+
bru.setEnvVar("transaction-key", data.results[0].key);
26+
}
27+
if(data.version){
28+
bru.setEnvVar("transaction-version", data.version);
29+
}
30+
if(data.id){
31+
bru.setEnvVar("transaction-id", data.id);
32+
}
33+
if(data.key){
34+
bru.setEnvVar("transaction-key", data.key);
35+
}
36+
37+
}
38+
}
39+
40+
assert {
41+
res.status: in [200, 201]
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
meta {
2+
name: get ByProjectKeyTransactionsKeyByKey
3+
type: http
4+
seq: 6
5+
}
6+
7+
get {
8+
url: {{apiUrl}}/{{project-key}}/transactions/key={{transaction-key}}
9+
body: none
10+
auth: inherit
11+
}
12+
13+
14+
query {
15+
}
16+
17+
script:post-response {
18+
var data = res.body;
19+
if(res.status == 200 || res.status == 201) {
20+
if(data.results && data.results[0] && data.results[0].id && data.results[0].version){
21+
bru.setEnvVar("transaction-id", data.results[0].id);
22+
bru.setEnvVar("transaction-version", data.results[0].version);
23+
}
24+
if(data.results && data.results[0] && data.results[0].key){
25+
bru.setEnvVar("transaction-key", data.results[0].key);
26+
}
27+
if(data.version){
28+
bru.setEnvVar("transaction-version", data.version);
29+
}
30+
if(data.id){
31+
bru.setEnvVar("transaction-id", data.id);
32+
}
33+
if(data.key){
34+
bru.setEnvVar("transaction-key", data.key);
35+
}
36+
37+
}
38+
}
39+
40+
assert {
41+
res.status: in [200, 201]
42+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
meta {
2+
name: post ByProjectKeyTransactions
3+
type: http
4+
seq: 3
5+
}
6+
7+
post {
8+
url: {{apiUrl}}/{{project-key}}/transactions
9+
body: json
10+
auth: inherit
11+
}
12+
13+
body:json {
14+
{
15+
"key" : "transaction-key",
16+
"application" : {
17+
"typeId" : "application",
18+
"id" : "a84d4fe7-ae82-4c3f-8c6c-435e54204fdd"
19+
},
20+
"cart" : {
21+
"typeId" : "cart",
22+
"id" : "a0e60229-441c-44b0-952b-981a67cbd8c4"
23+
},
24+
"transactionItems" : [ {
25+
"paymentIntegration" : {
26+
"typeId" : "payment-integration",
27+
"id" : "4c24762b-87df-4bd3-898a-bafed913a9ca"
28+
},
29+
"amount" : {
30+
"centAmount" : 1000,
31+
"currencyCode" : "EUR"
32+
}
33+
} ]
34+
}
35+
}
36+
37+
query {
38+
}
39+
40+
script:post-response {
41+
var data = res.body;
42+
if(res.status == 200 || res.status == 201) {
43+
if(data.results && data.results[0] && data.results[0].id && data.results[0].version){
44+
bru.setEnvVar("transaction-id", data.results[0].id);
45+
bru.setEnvVar("transaction-version", data.results[0].version);
46+
}
47+
if(data.results && data.results[0] && data.results[0].key){
48+
bru.setEnvVar("transaction-key", data.results[0].key);
49+
}
50+
if(data.version){
51+
bru.setEnvVar("transaction-version", data.version);
52+
}
53+
if(data.id){
54+
bru.setEnvVar("transaction-id", data.id);
55+
}
56+
if(data.key){
57+
bru.setEnvVar("transaction-key", data.key);
58+
}
59+
60+
}
61+
}
62+
63+
assert {
64+
res.status: in [200, 201]
65+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
meta {
2+
name: Client Credentials
3+
type: http
4+
seq: 1
5+
}
6+
7+
post {
8+
url: {{authUrl}}/oauth/token
9+
body: formUrlEncoded
10+
auth: basic
11+
}
12+
13+
body:form-urlencoded {
14+
grant_type: client_credentials
15+
}
16+
17+
auth:basic {
18+
username: {{ctp_client_id}}
19+
password: {{ctp_client_secret}}
20+
}
21+
22+
script:post-response {
23+
if(res.status == 200) {
24+
var data = res.body;
25+
if(data.access_token){
26+
bru.setEnvVar("ctp_access_token", data.access_token, true);
27+
}
28+
29+
if (data.scope) {
30+
parts = data.scope.split(" ");
31+
parts = parts.filter(scope => scope.includes(":")).map(scope => scope.split(":"))
32+
if (parts.length > 0) {
33+
scopeParts = parts[0];
34+
bru.setEnvVar("project-key", scopeParts[1]);
35+
parts = parts.filter(scope => scope.length >= 3)
36+
if (parts.length > 0) {
37+
scopeParts = parts[0];
38+
bru.setEnvVar("store-key", scopeParts[2]);
39+
}
40+
}
41+
}
42+
}
43+
}
44+
45+
assert {
46+
res.status: eq 200
47+
}

bruno/checkout/bruno.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"version": "1",
3+
"name": "Checkout API",
4+
"type": "collection",
5+
"ignore": [
6+
"node_modules",
7+
".git"
8+
]
9+
}

bruno/checkout/collection.bru

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
headers {
2+
User-Agent: bruno/0.1.0
3+
}
4+
5+
auth {
6+
mode: bearer
7+
}
8+
9+
auth:bearer {
10+
token: {{ctp_access_token}}
11+
}
12+
13+
docs {
14+
# commercetools API Bruno Collection
15+
16+
This collection contains examples of requests and responses for most endpoints and commands of the
17+
Checkout API. For every command the smallest possible payload is given. Please find optional
18+
fields in the related official documentation. Additionally the collection provides example requests and
19+
responses for specific tasks and more complex data models.
20+
21+
## Disclaimer
22+
23+
This is not the official Checkout API documentation. Please see [here](http://docs.commercetools.com/)
24+
for a complete and approved documentation of the Checkout API.
25+
26+
## How to use
27+
28+
**:warning: Be aware that postman automatically synchronizes environment variables (including your API client credentials) to your workspace if logged in.
29+
Use this collection only for development purposes and non-production projects.**
30+
31+
To use this collection in Bruno please perform the following steps:
32+
33+
1. Download and install the Bruno Client
34+
1. Fork the repository
35+
1. Open the collection
36+
1. In the Merchant Center, create a new API Client
37+
1. Select the environment and configure the client credentials in the variable `ctp_client_id` and `ctp_client_secret`
38+
or create an `.env` file and put it in the collection folder. An sample file is part of the collection.
39+
1. Obtain an access token by sending the "Auth/Client credentials" request. Now you can use all other endpoints
40+
41+
Feel free to clone and modify this collection to your needs. This collection gets automatically
42+
updated and you can pull the latest changes.
43+
44+
To automate frequent tasks the collection automatically manages commonly required values and parameters such
45+
as resource ids, keys and versions in environment variables for you.
46+
47+
Please see http://docs.commercetools.com/ for further information about the commercetools Plattform.
48+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
vars {
2+
authUrl: {{process.env.CTP_AUTH_URL}}
3+
apiUrl: {{process.env.CTP_API_URL}}
4+
project-key: {{process.env.CTP_PROJECT_KEY}}
5+
ctp_client_id: {{process.env.CTP_CLIENT_ID}}
6+
ctp_client_secret: {{process.env.CTP_CLIENT_SECRET}}
7+
username: {{process.env.CTP_USERNAME}}
8+
password: {{process.env.CTP_USER_PWD}}
9+
}
10+
vars:secret [
11+
ctp_access_token
12+
]

0 commit comments

Comments
 (0)