Skip to content

Commit

Permalink
Release v0.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Dec 7, 2023
1 parent 7e4dd72 commit 9818cbb
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 71 deletions.
2 changes: 1 addition & 1 deletion core/client_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ func (c *ClientOptions) cloneHeader() http.Header {
headers := c.HTTPHeader.Clone()
headers.Set("X-Fern-Language", "Go")
headers.Set("X-Fern-SDK-Name", "github.com/FlatFilers/flatfile-go")
headers.Set("X-Fern-SDK-Version", "0.0.4")
headers.Set("X-Fern-SDK-Version", "v0.0.5")
return headers
}
40 changes: 40 additions & 0 deletions jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,3 +410,43 @@ func (l *ListJobsResponse) String() string {
}
return fmt.Sprintf("%#v", l)
}

type MutateJobConfig struct {
SheetId SheetId `json:"sheetId"`
// A JavaScript function that will be run on each record in the sheet, it should return a mutated record.
MutateRecord string `json:"mutateRecord"`
// If the mutation was generated through some sort of id-ed process, this links this job and that process.
MutationId *string `json:"mutationId,omitempty"`
Filter *Filter `json:"filter,omitempty"`
FilterField *FilterField `json:"filterField,omitempty"`
SearchValue *SearchValue `json:"searchValue,omitempty"`
SearchField *SearchField `json:"searchField,omitempty"`
Q *string `json:"q,omitempty"`
// The Record Ids param (ids) is a list of record ids that can be passed to several record endpoints allowing the user to identify specific records to INCLUDE in the query, or specific records to EXCLUDE, depending on whether or not filters are being applied. When passing a query param that filters the record dataset, such as 'searchValue', or a 'filter' of 'valid' | 'error' | 'all', the 'ids' param will EXCLUDE those records from the filtered results. For basic queries that do not filter the dataset, passing record ids in the 'ids' param will limit the dataset to INCLUDE just those specific records
Ids []RecordId `json:"ids,omitempty"`

_rawJSON json.RawMessage
}

func (m *MutateJobConfig) UnmarshalJSON(data []byte) error {
type unmarshaler MutateJobConfig
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*m = MutateJobConfig(value)
m._rawJSON = json.RawMessage(data)
return nil
}

func (m *MutateJobConfig) String() string {
if len(m._rawJSON) > 0 {
if value, err := core.StringifyJSON(m._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(m); err == nil {
return value
}
return fmt.Sprintf("%#v", m)
}
24 changes: 24 additions & 0 deletions jobs/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,30 @@ func (c *Client) Retry(ctx context.Context, jobId flatfilego.JobId) (*flatfilego
return response, nil
}

// Preview the results of a mutation
func (c *Client) PreviewMutation(ctx context.Context, request *flatfilego.MutateJobConfig) (*flatfilego.DiffRecordsResponse, error) {
baseURL := "https://api.x.flatfile.com/v1"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := baseURL + "/" + "jobs/preview-mutation"

var response *flatfilego.DiffRecordsResponse
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
}

// Split a job and return the job
//
// ID of job to return
Expand Down
29 changes: 0 additions & 29 deletions snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,6 @@ type ListSnapshotRequest struct {
// Snapshot ID
type SnapshotId = string

type DiffRecordsResponse struct {
Data DiffRecords `json:"data,omitempty"`

_rawJSON json.RawMessage
}

func (d *DiffRecordsResponse) UnmarshalJSON(data []byte) error {
type unmarshaler DiffRecordsResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*d = DiffRecordsResponse(value)
d._rawJSON = json.RawMessage(data)
return nil
}

func (d *DiffRecordsResponse) String() string {
if len(d._rawJSON) > 0 {
if value, err := core.StringifyJSON(d._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(d); err == nil {
return value
}
return fmt.Sprintf("%#v", d)
}

// Options to filter records in a snapshot
type ChangeType string

Expand Down
Loading

0 comments on commit 9818cbb

Please sign in to comment.