-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
459 additions
and
241 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,60 @@ | ||
// Package swervpay provides a set of APIs to interact with the Swervpay service. | ||
package swervpay | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
) | ||
|
||
// Business represents a business entity in the Swervpay system. | ||
// It includes various properties like address, name, country, etc. | ||
type Business struct { | ||
Address string `json:"address"` | ||
Name string `json:"name"` | ||
Country string `json:"country"` | ||
CreatedAt string `json:"created_at"` | ||
Email string `json:"email"` | ||
ID string `json:"id"` | ||
Logo string `json:"logo"` | ||
Slug string `json:"slug"` | ||
Type string `json:"type"` | ||
UpdatedAt string `json:"updated_at"` | ||
Address string `json:"address"` // Address of the business | ||
Name string `json:"name"` // Name of the business | ||
Country string `json:"country"` // Country where the business is located | ||
CreatedAt string `json:"created_at"` // Time when the business was created | ||
Email string `json:"email"` // Email of the business | ||
ID string `json:"id"` // Unique identifier of the business | ||
Logo string `json:"logo"` // Logo of the business | ||
Slug string `json:"slug"` // Slug of the business | ||
Type string `json:"type"` // Type of the business | ||
UpdatedAt string `json:"updated_at"` // Time when the business was last updated | ||
} | ||
|
||
// BusinessInt is an interface that defines the methods a Business must have. | ||
type BusinessInt interface { | ||
// Get retrieves the Business information from the Swervpay system. | ||
Get(ctx context.Context) (*Business, error) | ||
} | ||
|
||
// BusinessIntImpl is a concrete implementation of the BusinessInt interface. | ||
type BusinessIntImpl struct { | ||
client *SwervpayClient | ||
client *SwervpayClient // Client used to make requests to the Swervpay system | ||
} | ||
|
||
// Ensure BusinessIntImpl implements BusinessInt interface | ||
var _ BusinessInt = &BusinessIntImpl{} | ||
|
||
// Get is a method on BusinessIntImpl that retrieves the Business information from the Swervpay system. | ||
// https://docs.swervpay.co/api-reference/business/get | ||
func (b *BusinessIntImpl) Get(ctx context.Context) (*Business, error) { | ||
// Prepare request | ||
|
||
// Create a new request to get the business information | ||
req, err := b.client.NewRequest(ctx, http.MethodGet, "business", nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// Response will hold the business information | ||
response := new(Business) | ||
|
||
// Perform the request and populate the response | ||
_, err = b.client.Perform(req, response) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// Return the business information | ||
return response, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.