Skip to content

Commit

Permalink
Release 0.1.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
WorldlineAcquiring committed Sep 20, 2024
1 parent 0065ccc commit e6b9028
Show file tree
Hide file tree
Showing 133 changed files with 9,193 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.gitattributes export-ignore
.gitignore export-ignore

* text eol=lf
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#IntelIij IDEA files
*.iml
.idea/

# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
*.test
*.prof

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

.tags

# Visual Studio Code files
.vscode
56 changes: 56 additions & 0 deletions Client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// This file was automatically generated.

package acquiringsdk

import (
"github.com/Worldline-Acquiring/acquiring-sdk-go/apiv1"
"github.com/Worldline-Acquiring/acquiring-sdk-go/communicator"
"github.com/Worldline-Acquiring/acquiring-sdk-go/logging"
"github.com/Worldline-Acquiring/acquiring-sdk-go/logging/obfuscation"
)

// Client is the Worldline Acquiring platform client. Thread-safe.
type Client struct {
apiResource *communicator.APIResource
}

// SetBodyObfuscator sets the body obfuscator to use.
func (c *Client) SetBodyObfuscator(bodyObfuscator obfuscation.BodyObfuscator) {
c.apiResource.Communicator().SetBodyObfuscator(bodyObfuscator)
}

// SetHeaderObfuscator sets the header obfuscator to use.
func (c *Client) SetHeaderObfuscator(headerObfuscator obfuscation.HeaderObfuscator) {
c.apiResource.Communicator().SetHeaderObfuscator(headerObfuscator)
}

// EnableLogging turns on logging using the given communicator logger.
func (c *Client) EnableLogging(communicatorLogger logging.CommunicatorLogger) {
c.apiResource.Communicator().EnableLogging(communicatorLogger)
}

// DisableLogging turns off logging.
func (c *Client) DisableLogging() {
c.apiResource.Communicator().DisableLogging()
}

// Close calls the internal closer of the communicator
func (c *Client) Close() error {
return c.apiResource.Communicator().Close()
}

// V1 represents API v1
func (c *Client) V1() *apiv1.Client {
client, _ := apiv1.NewClient(c.apiResource, nil)
return client
}

// NewClient creates a new Client with the given communicator
func NewClient(comm *communicator.Communicator) (*Client, error) {
apiResource, err := communicator.NewAPIResource(comm, nil)
if err != nil {
return nil, err
}

return &Client{apiResource}, nil
}
63 changes: 63 additions & 0 deletions CommunicatorBuilder.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package acquiringsdk

import (
"net/url"

"github.com/Worldline-Acquiring/acquiring-sdk-go/authentication"
"github.com/Worldline-Acquiring/acquiring-sdk-go/communicator"
"github.com/Worldline-Acquiring/acquiring-sdk-go/json"
)

// CommunicatorBuilder is the builder for Communicator objects
type CommunicatorBuilder struct {
APIEndpoint *url.URL
Connection communicator.Connection
MetadataProvider *communicator.MetadataProvider
Authenticator authentication.Authenticator
Marshaller json.Marshaller
}

// WithAPIEndpoint sets the Worldline Acquiring platform API endpoint to be used by the Communicator
func (c *CommunicatorBuilder) WithAPIEndpoint(endpoint *url.URL) *CommunicatorBuilder {
c.APIEndpoint = endpoint

return c
}

// WithConnection sets the Connection to be used by the Communicator
func (c *CommunicatorBuilder) WithConnection(connection communicator.Connection) *CommunicatorBuilder {
c.Connection = connection

return c
}

// WithMetadataProvider sets the MetadataProvider to be used by the Communicator
func (c *CommunicatorBuilder) WithMetadataProvider(provider *communicator.MetadataProvider) *CommunicatorBuilder {
c.MetadataProvider = provider

return c
}

// WithAuthenticator sets the Authenticator to be used by the Communicator
func (c *CommunicatorBuilder) WithAuthenticator(auth authentication.Authenticator) *CommunicatorBuilder {
c.Authenticator = auth

return c
}

// WithMarshaller sets the Marshaller to be used by the Communicator
func (c *CommunicatorBuilder) WithMarshaller(marshaller json.Marshaller) *CommunicatorBuilder {
c.Marshaller = marshaller

return c
}

// Build creates a Communicator object based on the builder parameters
func (c *CommunicatorBuilder) Build() (*communicator.Communicator, error) {
return communicator.NewCommunicator(c.APIEndpoint, c.Connection, c.Authenticator, c.MetadataProvider, c.Marshaller)
}

// NewCommunicatorBuilder creates a CommunicatorBuilder object
func NewCommunicatorBuilder() *CommunicatorBuilder {
return &CommunicatorBuilder{}
}
Loading

0 comments on commit e6b9028

Please sign in to comment.