-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
72b10cf
commit b924b53
Showing
39 changed files
with
4,332 additions
and
1,522 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// This file was auto-generated by Fern from our API Definition. | ||
|
||
package api | ||
|
||
type ActionResponse = *ApiAction | ||
|
||
type Actions = []*Action | ||
|
||
type ActionsResponse = []*ApiAction |
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 |
---|---|---|
@@ -0,0 +1,223 @@ | ||
// This file was auto-generated by Fern from our API Definition. | ||
|
||
package actions | ||
|
||
import ( | ||
context "context" | ||
flatfilego "github.com/FlatFilers/flatfile-go" | ||
core "github.com/FlatFilers/flatfile-go/core" | ||
option "github.com/FlatFilers/flatfile-go/option" | ||
http "net/http" | ||
) | ||
|
||
type Client struct { | ||
baseURL string | ||
caller *core.Caller | ||
header http.Header | ||
} | ||
|
||
func NewClient(opts ...option.RequestOption) *Client { | ||
options := core.NewRequestOptions(opts...) | ||
return &Client{ | ||
baseURL: options.BaseURL, | ||
caller: core.NewCaller( | ||
&core.CallerParams{ | ||
Client: options.HTTPClient, | ||
MaxAttempts: options.MaxAttempts, | ||
}, | ||
), | ||
header: options.ToHeader(), | ||
} | ||
} | ||
|
||
func (c *Client) Create( | ||
ctx context.Context, | ||
request *flatfilego.Action, | ||
opts ...option.RequestOption, | ||
) (flatfilego.ActionResponse, error) { | ||
options := core.NewRequestOptions(opts...) | ||
|
||
baseURL := "https://api.x.flatfile.com/v1" | ||
if c.baseURL != "" { | ||
baseURL = c.baseURL | ||
} | ||
if options.BaseURL != "" { | ||
baseURL = options.BaseURL | ||
} | ||
endpointURL := baseURL + "/actions" | ||
|
||
headers := core.MergeHeaders(c.header.Clone(), options.ToHeader()) | ||
|
||
var response flatfilego.ActionResponse | ||
if err := c.caller.Call( | ||
ctx, | ||
&core.CallParams{ | ||
URL: endpointURL, | ||
Method: http.MethodPost, | ||
MaxAttempts: options.MaxAttempts, | ||
Headers: headers, | ||
BodyProperties: options.BodyProperties, | ||
QueryParameters: options.QueryParameters, | ||
Client: options.HTTPClient, | ||
Request: request, | ||
Response: &response, | ||
}, | ||
); err != nil { | ||
return nil, err | ||
} | ||
return response, nil | ||
} | ||
|
||
func (c *Client) BulkCreate( | ||
ctx context.Context, | ||
request flatfilego.Actions, | ||
opts ...option.RequestOption, | ||
) (flatfilego.ActionsResponse, error) { | ||
options := core.NewRequestOptions(opts...) | ||
|
||
baseURL := "https://api.x.flatfile.com/v1" | ||
if c.baseURL != "" { | ||
baseURL = c.baseURL | ||
} | ||
if options.BaseURL != "" { | ||
baseURL = options.BaseURL | ||
} | ||
endpointURL := baseURL + "/actions/bulk" | ||
|
||
headers := core.MergeHeaders(c.header.Clone(), options.ToHeader()) | ||
|
||
var response flatfilego.ActionsResponse | ||
if err := c.caller.Call( | ||
ctx, | ||
&core.CallParams{ | ||
URL: endpointURL, | ||
Method: http.MethodPost, | ||
MaxAttempts: options.MaxAttempts, | ||
Headers: headers, | ||
BodyProperties: options.BodyProperties, | ||
QueryParameters: options.QueryParameters, | ||
Client: options.HTTPClient, | ||
Request: request, | ||
Response: &response, | ||
}, | ||
); err != nil { | ||
return nil, err | ||
} | ||
return response, nil | ||
} | ||
|
||
func (c *Client) Get( | ||
ctx context.Context, | ||
// The id of the action to return | ||
actionId flatfilego.ActionId, | ||
opts ...option.RequestOption, | ||
) (flatfilego.ActionResponse, error) { | ||
options := core.NewRequestOptions(opts...) | ||
|
||
baseURL := "https://api.x.flatfile.com/v1" | ||
if c.baseURL != "" { | ||
baseURL = c.baseURL | ||
} | ||
if options.BaseURL != "" { | ||
baseURL = options.BaseURL | ||
} | ||
endpointURL := core.EncodeURL(baseURL+"/actions/%v", actionId) | ||
|
||
headers := core.MergeHeaders(c.header.Clone(), options.ToHeader()) | ||
|
||
var response flatfilego.ActionResponse | ||
if err := c.caller.Call( | ||
ctx, | ||
&core.CallParams{ | ||
URL: endpointURL, | ||
Method: http.MethodGet, | ||
MaxAttempts: options.MaxAttempts, | ||
Headers: headers, | ||
BodyProperties: options.BodyProperties, | ||
QueryParameters: options.QueryParameters, | ||
Client: options.HTTPClient, | ||
Response: &response, | ||
}, | ||
); err != nil { | ||
return nil, err | ||
} | ||
return response, nil | ||
} | ||
|
||
func (c *Client) Update( | ||
ctx context.Context, | ||
// The id of the action to patch | ||
actionId flatfilego.ActionId, | ||
request *flatfilego.ActionUpdate, | ||
opts ...option.RequestOption, | ||
) (flatfilego.ActionResponse, error) { | ||
options := core.NewRequestOptions(opts...) | ||
|
||
baseURL := "https://api.x.flatfile.com/v1" | ||
if c.baseURL != "" { | ||
baseURL = c.baseURL | ||
} | ||
if options.BaseURL != "" { | ||
baseURL = options.BaseURL | ||
} | ||
endpointURL := core.EncodeURL(baseURL+"/actions/%v", actionId) | ||
|
||
headers := core.MergeHeaders(c.header.Clone(), options.ToHeader()) | ||
|
||
var response flatfilego.ActionResponse | ||
if err := c.caller.Call( | ||
ctx, | ||
&core.CallParams{ | ||
URL: endpointURL, | ||
Method: http.MethodPatch, | ||
MaxAttempts: options.MaxAttempts, | ||
Headers: headers, | ||
BodyProperties: options.BodyProperties, | ||
QueryParameters: options.QueryParameters, | ||
Client: options.HTTPClient, | ||
Request: request, | ||
Response: &response, | ||
}, | ||
); err != nil { | ||
return nil, err | ||
} | ||
return response, nil | ||
} | ||
|
||
func (c *Client) Delete( | ||
ctx context.Context, | ||
// The id of the action to delete | ||
actionId flatfilego.ActionId, | ||
opts ...option.RequestOption, | ||
) (*flatfilego.Success, error) { | ||
options := core.NewRequestOptions(opts...) | ||
|
||
baseURL := "https://api.x.flatfile.com/v1" | ||
if c.baseURL != "" { | ||
baseURL = c.baseURL | ||
} | ||
if options.BaseURL != "" { | ||
baseURL = options.BaseURL | ||
} | ||
endpointURL := core.EncodeURL(baseURL+"/actions/%v", actionId) | ||
|
||
headers := core.MergeHeaders(c.header.Clone(), options.ToHeader()) | ||
|
||
var response *flatfilego.Success | ||
if err := c.caller.Call( | ||
ctx, | ||
&core.CallParams{ | ||
URL: endpointURL, | ||
Method: http.MethodDelete, | ||
MaxAttempts: options.MaxAttempts, | ||
Headers: headers, | ||
BodyProperties: options.BodyProperties, | ||
QueryParameters: options.QueryParameters, | ||
Client: options.HTTPClient, | ||
Response: &response, | ||
}, | ||
); err != nil { | ||
return nil, err | ||
} | ||
return response, nil | ||
} |
Oops, something went wrong.