Skip to content

Commit

Permalink
feat: updated sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
demeyerthom committed Feb 21, 2024
1 parent 6167676 commit cc17f1b
Show file tree
Hide file tree
Showing 191 changed files with 4,688 additions and 1,350 deletions.
3 changes: 3 additions & 0 deletions .changes/unreleased/Added-20240221-114312.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Added
body: Updated api specs
time: 2024-02-21T11:43:12.907894501+01:00
10 changes: 8 additions & 2 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ vars:
codegenJar: "../rmf-codegen/rmf-codegen.jar"
apiSpecsDir: "../commercetools-api-reference/api-specs"
generatedDir: "./generated"
versionId: 1.3.0
versionId: 1.5.0

tasks:
install:
Expand All @@ -29,8 +29,9 @@ tasks:
- task: generate-connect
- task: generate-importapi
- task: generate-frontend
- task: generate-ml
# - task: generate-ml
- task: generate-platform
- task: generate-history

generate-checkout:
cmds:
Expand Down Expand Up @@ -62,6 +63,11 @@ tasks:
- task: generate-api
vars: {apiName: platform, path: api}

generate-history:
cmds:
- task: generate-api
vars: {apiName: history, path: history}

generate-api:
cmds:
- java -jar {{ .codegenJar }} generate {{ .apiSpecsDir }}/{{ .path }}/api.raml -b {{ .apiName }} -o {{ .generatedDir }}/ -t GO_CLIENT
Expand Down
2 changes: 1 addition & 1 deletion checkout/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

// Version identifies the current library version. Should match the git tag
const Version = "1.4.1"
const Version = "1.5.0"

type Client struct {
httpClient *http.Client
Expand Down
7 changes: 7 additions & 0 deletions checkout/client_api_root.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
package checkout

// Generated file, please do not change!!!

func (c *Client) WithProjectKey(projectKey string) *ByProjectKeyRequestBuilder {
return &ByProjectKeyRequestBuilder{
projectKey: projectKey,
client: c,
}
}
15 changes: 15 additions & 0 deletions checkout/client_by_project_key.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package checkout

// Generated file, please do not change!!!

type ByProjectKeyRequestBuilder struct {
projectKey string
client *Client
}

func (rb *ByProjectKeyRequestBuilder) PaymentIntents() *ByProjectKeyPaymentIntentsRequestBuilder {
return &ByProjectKeyPaymentIntentsRequestBuilder{
projectKey: rb.projectKey,
client: rb.client,
}
}
16 changes: 16 additions & 0 deletions checkout/client_payment_intents_by_project_key_payment_intents.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package checkout

// Generated file, please do not change!!!

type ByProjectKeyPaymentIntentsRequestBuilder struct {
projectKey string
client *Client
}

func (rb *ByProjectKeyPaymentIntentsRequestBuilder) WithPaymentId(paymentId string) *ByProjectKeyPaymentIntentsByPaymentIdRequestBuilder {
return &ByProjectKeyPaymentIntentsByPaymentIdRequestBuilder{
paymentId: paymentId,
projectKey: rb.projectKey,
client: rb.client,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package checkout

// Generated file, please do not change!!!

import (
"fmt"
)

type ByProjectKeyPaymentIntentsByPaymentIdRequestBuilder struct {
projectKey string
paymentId string
client *Client
}

/**
* Specific Error Codes:
* - [MultipleActionsNotAllowed](ctp:checkout:type:MultipleActionsNotAllowedError)
* - [RequiredField](ctp:checkout:type:RequiredFieldError)
* - [ResourceNotFound](ctp:checkout:type:ResourceNotFoundError)
*
*/
func (rb *ByProjectKeyPaymentIntentsByPaymentIdRequestBuilder) Post(body Payment) *ByProjectKeyPaymentIntentsByPaymentIdRequestMethodPost {
return &ByProjectKeyPaymentIntentsByPaymentIdRequestMethodPost{
body: body,
url: fmt.Sprintf("/%s/payment-intents/%s", rb.projectKey, rb.paymentId),
client: rb.client,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package checkout

// Generated file, please do not change!!!

import (
"context"
"encoding/json"
"io/ioutil"
"net/http"
"net/url"
)

type ByProjectKeyPaymentIntentsByPaymentIdRequestMethodPost struct {
body Payment
url string
client *Client
headers http.Header
}

func (r *ByProjectKeyPaymentIntentsByPaymentIdRequestMethodPost) Dump() map[string]interface{} {
return map[string]interface{}{
"url": r.url,
}
}

func (rb *ByProjectKeyPaymentIntentsByPaymentIdRequestMethodPost) WithHeaders(headers http.Header) *ByProjectKeyPaymentIntentsByPaymentIdRequestMethodPost {
rb.headers = headers
return rb
}

/**
* Specific Error Codes:
* - [MultipleActionsNotAllowed](ctp:checkout:type:MultipleActionsNotAllowedError)
* - [RequiredField](ctp:checkout:type:RequiredFieldError)
* - [ResourceNotFound](ctp:checkout:type:ResourceNotFoundError)
*
*/
func (rb *ByProjectKeyPaymentIntentsByPaymentIdRequestMethodPost) Execute(ctx context.Context) (result *interface{}, err error) {
data, err := serializeInput(rb.body)
if err != nil {
return nil, err
}
queryParams := url.Values{}
resp, err := rb.client.post(
ctx,
rb.url,
queryParams,
rb.headers,
data,
)

if err != nil {
return nil, err
}
content, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
defer resp.Body.Close()
switch resp.StatusCode {
case 200:
err = json.Unmarshal(content, &result)
if err != nil {
return nil, err
}
return result, nil
default:
result := GenericRequestError{
StatusCode: resp.StatusCode,
Content: content,
Response: resp,
}
return nil, result
}

}
52 changes: 52 additions & 0 deletions checkout/types_common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package checkout

// Generated file, please do not change!!!

/**
* The Region in which the Checkout application is [hosted](/../checkout/installing-checkout#regions-and-hosts).
*
*/
type Region string

const (
RegionEuropeWest1Gcp Region = "europe-west1.gcp"
RegionUsCentral1Gcp Region = "us-central1.gcp"
RegionAustraliaSoutheast1Gcp Region = "australia-southeast1.gcp"
)

/**
* The amount related to a [payment action](ctp:checkout:type:PaymentAction).
*
*/
type Amount struct {
// Amount in the smallest indivisible unit of a currency, such as:
//
// * Cents for EUR and USD, pence for GBP, or centime for CHF (5 CHF is specified as `500`).
// * The value in the major unit for currencies without minor units, like JPY (5 JPY is specified as `5`).
CentAmount int `json:"centAmount"`
// Currency code compliant to [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217).
CurrencyCode string `json:"currencyCode"`
}

/**
* The possible values for a [payment action](ctp:checkout:type:PaymentAction).
*
*/
type PaymentOperation string

const (
PaymentOperationCapturePayment PaymentOperation = "capturePayment"
PaymentOperationRefundPayment PaymentOperation = "refundPayment"
PaymentOperationCancelPayment PaymentOperation = "cancelPayment"
)

/**
* Depending on the action specified, Checkout requests the [Payment Service Provider](/../checkout/configuring-checkout#supported-payment-service-providers) to capture, refund, or cancel the authorization for the given Payment.
*
*/
type PaymentAction struct {
// Action to execute for the given Payment.
Action PaymentOperation `json:"action"`
// Amount to be captured or refunded.
Amount *Amount `json:"amount,omitempty"`
}
Loading

0 comments on commit cc17f1b

Please sign in to comment.