-
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
c088307
commit 20814c8
Showing
16 changed files
with
866 additions
and
95 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// This file was auto-generated by Fern from our API Definition. | ||
|
||
package api | ||
|
||
import ( | ||
json "encoding/json" | ||
fmt "fmt" | ||
core "github.com/FlatFilers/flatfile-go/core" | ||
) | ||
|
||
// Properties used to update an account | ||
type AccountPatch struct { | ||
DefaultAppId AppId `json:"defaultAppId" url:"defaultAppId"` | ||
|
||
_rawJSON json.RawMessage | ||
} | ||
|
||
func (a *AccountPatch) UnmarshalJSON(data []byte) error { | ||
type unmarshaler AccountPatch | ||
var value unmarshaler | ||
if err := json.Unmarshal(data, &value); err != nil { | ||
return err | ||
} | ||
*a = AccountPatch(value) | ||
a._rawJSON = json.RawMessage(data) | ||
return nil | ||
} | ||
|
||
func (a *AccountPatch) String() string { | ||
if len(a._rawJSON) > 0 { | ||
if value, err := core.StringifyJSON(a._rawJSON); err == nil { | ||
return value | ||
} | ||
} | ||
if value, err := core.StringifyJSON(a); err == nil { | ||
return value | ||
} | ||
return fmt.Sprintf("%#v", a) | ||
} | ||
|
||
type AccountResponse struct { | ||
Data *Account `json:"data,omitempty" url:"data,omitempty"` | ||
|
||
_rawJSON json.RawMessage | ||
} | ||
|
||
func (a *AccountResponse) UnmarshalJSON(data []byte) error { | ||
type unmarshaler AccountResponse | ||
var value unmarshaler | ||
if err := json.Unmarshal(data, &value); err != nil { | ||
return err | ||
} | ||
*a = AccountResponse(value) | ||
a._rawJSON = json.RawMessage(data) | ||
return nil | ||
} | ||
|
||
func (a *AccountResponse) String() string { | ||
if len(a._rawJSON) > 0 { | ||
if value, err := core.StringifyJSON(a._rawJSON); err == nil { | ||
return value | ||
} | ||
} | ||
if value, err := core.StringifyJSON(a); err == nil { | ||
return value | ||
} | ||
return fmt.Sprintf("%#v", a) | ||
} |
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,103 @@ | ||
// This file was auto-generated by Fern from our API Definition. | ||
|
||
package accounts | ||
|
||
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(), | ||
} | ||
} | ||
|
||
// Get the current account | ||
func (c *Client) GetCurrent( | ||
ctx context.Context, | ||
opts ...option.RequestOption, | ||
) (*flatfilego.AccountResponse, 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 + "/" + "accounts/current" | ||
|
||
headers := core.MergeHeaders(c.header.Clone(), options.ToHeader()) | ||
|
||
var response *flatfilego.AccountResponse | ||
if err := c.caller.Call( | ||
ctx, | ||
&core.CallParams{ | ||
URL: endpointURL, | ||
Method: http.MethodGet, | ||
MaxAttempts: options.MaxAttempts, | ||
Headers: headers, | ||
Client: options.HTTPClient, | ||
Response: &response, | ||
}, | ||
); err != nil { | ||
return nil, err | ||
} | ||
return response, nil | ||
} | ||
|
||
// Update the current account | ||
func (c *Client) UpdateCurrent( | ||
ctx context.Context, | ||
request *flatfilego.AccountPatch, | ||
opts ...option.RequestOption, | ||
) (*flatfilego.AccountResponse, 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 + "/" + "accounts/current" | ||
|
||
headers := core.MergeHeaders(c.header.Clone(), options.ToHeader()) | ||
|
||
var response *flatfilego.AccountResponse | ||
if err := c.caller.Call( | ||
ctx, | ||
&core.CallParams{ | ||
URL: endpointURL, | ||
Method: http.MethodPatch, | ||
MaxAttempts: options.MaxAttempts, | ||
Headers: headers, | ||
Client: options.HTTPClient, | ||
Request: request, | ||
Response: &response, | ||
}, | ||
); err != nil { | ||
return nil, err | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
// This file was auto-generated by Fern from our API Definition. | ||
|
||
package api | ||
|
||
import ( | ||
json "encoding/json" | ||
fmt "fmt" | ||
core "github.com/FlatFilers/flatfile-go/core" | ||
) | ||
|
||
type ListPromptsRequest struct { | ||
// Number of prompts to return in a page (default 7) | ||
PageSize *int `json:"-" url:"pageSize,omitempty"` | ||
// Based on pageSize, which page of prompts to return | ||
PageNumber *int `json:"-" url:"pageNumber,omitempty"` | ||
} | ||
|
||
// Create a prompts | ||
type PromptCreate struct { | ||
Prompt string `json:"prompt" url:"prompt"` | ||
|
||
_rawJSON json.RawMessage | ||
} | ||
|
||
func (p *PromptCreate) UnmarshalJSON(data []byte) error { | ||
type unmarshaler PromptCreate | ||
var value unmarshaler | ||
if err := json.Unmarshal(data, &value); err != nil { | ||
return err | ||
} | ||
*p = PromptCreate(value) | ||
p._rawJSON = json.RawMessage(data) | ||
return nil | ||
} | ||
|
||
func (p *PromptCreate) String() string { | ||
if len(p._rawJSON) > 0 { | ||
if value, err := core.StringifyJSON(p._rawJSON); err == nil { | ||
return value | ||
} | ||
} | ||
if value, err := core.StringifyJSON(p); err == nil { | ||
return value | ||
} | ||
return fmt.Sprintf("%#v", p) | ||
} | ||
|
||
// Update a prompts | ||
type PromptPatch struct { | ||
Prompt *string `json:"prompt,omitempty" url:"prompt,omitempty"` | ||
|
||
_rawJSON json.RawMessage | ||
} | ||
|
||
func (p *PromptPatch) UnmarshalJSON(data []byte) error { | ||
type unmarshaler PromptPatch | ||
var value unmarshaler | ||
if err := json.Unmarshal(data, &value); err != nil { | ||
return err | ||
} | ||
*p = PromptPatch(value) | ||
p._rawJSON = json.RawMessage(data) | ||
return nil | ||
} | ||
|
||
func (p *PromptPatch) String() string { | ||
if len(p._rawJSON) > 0 { | ||
if value, err := core.StringifyJSON(p._rawJSON); err == nil { | ||
return value | ||
} | ||
} | ||
if value, err := core.StringifyJSON(p); err == nil { | ||
return value | ||
} | ||
return fmt.Sprintf("%#v", p) | ||
} | ||
|
||
type PromptResponse struct { | ||
Data *Prompt `json:"data,omitempty" url:"data,omitempty"` | ||
|
||
_rawJSON json.RawMessage | ||
} | ||
|
||
func (p *PromptResponse) UnmarshalJSON(data []byte) error { | ||
type unmarshaler PromptResponse | ||
var value unmarshaler | ||
if err := json.Unmarshal(data, &value); err != nil { | ||
return err | ||
} | ||
*p = PromptResponse(value) | ||
p._rawJSON = json.RawMessage(data) | ||
return nil | ||
} | ||
|
||
func (p *PromptResponse) String() string { | ||
if len(p._rawJSON) > 0 { | ||
if value, err := core.StringifyJSON(p._rawJSON); err == nil { | ||
return value | ||
} | ||
} | ||
if value, err := core.StringifyJSON(p); err == nil { | ||
return value | ||
} | ||
return fmt.Sprintf("%#v", p) | ||
} | ||
|
||
type PromptsResponse struct { | ||
Pagination *Pagination `json:"pagination,omitempty" url:"pagination,omitempty"` | ||
Data []*Prompt `json:"data,omitempty" url:"data,omitempty"` | ||
|
||
_rawJSON json.RawMessage | ||
} | ||
|
||
func (p *PromptsResponse) UnmarshalJSON(data []byte) error { | ||
type unmarshaler PromptsResponse | ||
var value unmarshaler | ||
if err := json.Unmarshal(data, &value); err != nil { | ||
return err | ||
} | ||
*p = PromptsResponse(value) | ||
p._rawJSON = json.RawMessage(data) | ||
return nil | ||
} | ||
|
||
func (p *PromptsResponse) String() string { | ||
if len(p._rawJSON) > 0 { | ||
if value, err := core.StringifyJSON(p._rawJSON); err == nil { | ||
return value | ||
} | ||
} | ||
if value, err := core.StringifyJSON(p); err == nil { | ||
return value | ||
} | ||
return fmt.Sprintf("%#v", p) | ||
} |
Oops, something went wrong.