-
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
cd1d8b8
commit 70f397d
Showing
15 changed files
with
2,420 additions
and
187 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,140 @@ | ||
// 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" | ||
time "time" | ||
) | ||
|
||
// Create an app | ||
type AppCreate struct { | ||
Name string `json:"name"` | ||
Namespace string `json:"namespace"` | ||
Type AppType `json:"type,omitempty"` | ||
Entity *string `json:"entity,omitempty"` | ||
EntityPlural *string `json:"entityPlural,omitempty"` | ||
Icon *string `json:"icon,omitempty"` | ||
Metadata interface{} `json:"metadata,omitempty"` | ||
|
||
_rawJSON json.RawMessage | ||
} | ||
|
||
func (a *AppCreate) UnmarshalJSON(data []byte) error { | ||
type unmarshaler AppCreate | ||
var value unmarshaler | ||
if err := json.Unmarshal(data, &value); err != nil { | ||
return err | ||
} | ||
*a = AppCreate(value) | ||
a._rawJSON = json.RawMessage(data) | ||
return nil | ||
} | ||
|
||
func (a *AppCreate) 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) | ||
} | ||
|
||
// Update an app | ||
type AppPatch struct { | ||
Name *string `json:"name,omitempty"` | ||
Namespace *string `json:"namespace,omitempty"` | ||
Entity *string `json:"entity,omitempty"` | ||
EntityPlural *string `json:"entityPlural,omitempty"` | ||
Icon *string `json:"icon,omitempty"` | ||
Metadata interface{} `json:"metadata,omitempty"` | ||
ActivatedAt *time.Time `json:"activatedAt,omitempty"` | ||
|
||
_rawJSON json.RawMessage | ||
} | ||
|
||
func (a *AppPatch) UnmarshalJSON(data []byte) error { | ||
type unmarshaler AppPatch | ||
var value unmarshaler | ||
if err := json.Unmarshal(data, &value); err != nil { | ||
return err | ||
} | ||
*a = AppPatch(value) | ||
a._rawJSON = json.RawMessage(data) | ||
return nil | ||
} | ||
|
||
func (a *AppPatch) 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 AppResponse struct { | ||
Data *App `json:"data,omitempty"` | ||
|
||
_rawJSON json.RawMessage | ||
} | ||
|
||
func (a *AppResponse) UnmarshalJSON(data []byte) error { | ||
type unmarshaler AppResponse | ||
var value unmarshaler | ||
if err := json.Unmarshal(data, &value); err != nil { | ||
return err | ||
} | ||
*a = AppResponse(value) | ||
a._rawJSON = json.RawMessage(data) | ||
return nil | ||
} | ||
|
||
func (a *AppResponse) 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 AppsResponse struct { | ||
Data []*App `json:"data,omitempty"` | ||
|
||
_rawJSON json.RawMessage | ||
} | ||
|
||
func (a *AppsResponse) UnmarshalJSON(data []byte) error { | ||
type unmarshaler AppsResponse | ||
var value unmarshaler | ||
if err := json.Unmarshal(data, &value); err != nil { | ||
return err | ||
} | ||
*a = AppsResponse(value) | ||
a._rawJSON = json.RawMessage(data) | ||
return nil | ||
} | ||
|
||
func (a *AppsResponse) 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,127 @@ | ||
// This file was auto-generated by Fern from our API Definition. | ||
|
||
package apps | ||
|
||
import ( | ||
context "context" | ||
fmt "fmt" | ||
flatfilego "github.com/FlatFilers/flatfile-go" | ||
core "github.com/FlatFilers/flatfile-go/core" | ||
http "net/http" | ||
) | ||
|
||
type Client struct { | ||
baseURL string | ||
caller *core.Caller | ||
header http.Header | ||
} | ||
|
||
func NewClient(opts ...core.ClientOption) *Client { | ||
options := core.NewClientOptions() | ||
for _, opt := range opts { | ||
opt(options) | ||
} | ||
return &Client{ | ||
baseURL: options.BaseURL, | ||
caller: core.NewCaller(options.HTTPClient), | ||
header: options.ToHeader(), | ||
} | ||
} | ||
|
||
// Returns apps in an account | ||
func (c *Client) List(ctx context.Context) (*flatfilego.AppsResponse, error) { | ||
baseURL := "https://api.x.flatfile.com/v1" | ||
if c.baseURL != "" { | ||
baseURL = c.baseURL | ||
} | ||
endpointURL := baseURL + "/" + "apps" | ||
|
||
var response *flatfilego.AppsResponse | ||
if err := c.caller.Call( | ||
ctx, | ||
&core.CallParams{ | ||
URL: endpointURL, | ||
Method: http.MethodGet, | ||
Headers: c.header, | ||
Response: &response, | ||
}, | ||
); err != nil { | ||
return nil, err | ||
} | ||
return response, nil | ||
} | ||
|
||
// Returns an app | ||
// | ||
// ID of app | ||
func (c *Client) Get(ctx context.Context, appId flatfilego.AppId) (*flatfilego.AppResponse, error) { | ||
baseURL := "https://api.x.flatfile.com/v1" | ||
if c.baseURL != "" { | ||
baseURL = c.baseURL | ||
} | ||
endpointURL := fmt.Sprintf(baseURL+"/"+"apps/%v", appId) | ||
|
||
var response *flatfilego.AppResponse | ||
if err := c.caller.Call( | ||
ctx, | ||
&core.CallParams{ | ||
URL: endpointURL, | ||
Method: http.MethodGet, | ||
Headers: c.header, | ||
Response: &response, | ||
}, | ||
); err != nil { | ||
return nil, err | ||
} | ||
return response, nil | ||
} | ||
|
||
// Updates an app | ||
// | ||
// ID of app | ||
func (c *Client) Update(ctx context.Context, appId flatfilego.AppId, request *flatfilego.AppPatch) (*flatfilego.AppResponse, error) { | ||
baseURL := "https://api.x.flatfile.com/v1" | ||
if c.baseURL != "" { | ||
baseURL = c.baseURL | ||
} | ||
endpointURL := fmt.Sprintf(baseURL+"/"+"apps/%v", appId) | ||
|
||
var response *flatfilego.AppResponse | ||
if err := c.caller.Call( | ||
ctx, | ||
&core.CallParams{ | ||
URL: endpointURL, | ||
Method: http.MethodPatch, | ||
Headers: c.header, | ||
Request: request, | ||
Response: &response, | ||
}, | ||
); err != nil { | ||
return nil, err | ||
} | ||
return response, nil | ||
} | ||
|
||
// Creates an app | ||
func (c *Client) Create(ctx context.Context, request *flatfilego.AppCreate) (*flatfilego.AppResponse, error) { | ||
baseURL := "https://api.x.flatfile.com/v1" | ||
if c.baseURL != "" { | ||
baseURL = c.baseURL | ||
} | ||
endpointURL := baseURL + "/" + "apps" | ||
|
||
var response *flatfilego.AppResponse | ||
if err := c.caller.Call( | ||
ctx, | ||
&core.CallParams{ | ||
URL: endpointURL, | ||
Method: http.MethodPost, | ||
Headers: c.header, | ||
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
Oops, something went wrong.