Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

flatfile_api

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flatfile_api

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

FlatfileApi

This software is an unofficial client for the Flatfile API, and is not endorsed by Flatfile.

It provides access to all available endpoints, but the documentation is patchy and most endpoints are untested. Use with caution.

If you can help document the endpoints, and provide example use cases, please feel free to send pull requests.

A note on naming conventions

The Flatfile API typically uses CamelCase for parameters, and hash key names (but not always). This gem converts everything to snake_case.

A note on pagination

Some of the endpoints are paginated; they can be identified as the ones that take skip and take as parameters. They are not required values and will default to 0 and 50 respectively. You can use these values to manage your own pagination, but you can also treat the response as an Enumerable and use each, map, find, etc. and it will automatically pull all results. Use with caution.

All the endpoints return either a FlatfileApi::Response or a FlatfileApi::PaginatedResponse.

On either response, use the data method to access the returned data.

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add flatfile_api

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install flatfile_api

Usage

Get recent uploads

require 'flatfile_api'

client = FlatfileApi.new access_key_id: '12345', secret_access_key: '1234-456790-1234'
uploads = client.list_workspace_uploads license_key: '9999-234234-2342'
# => <FlatfileApi::PaginatedResponse:0x00007f508bdd6020 ...>

# Access the page of results directly:
uploads.data.first
# => {
#  :license_id=>938427,
#  :team_id=>10483,
#  :environment_id=>"4248-585628-1322",
#  :workspace_id=>nil,
#  :schema_id=>nil,
#  :embed_id=>nil,
#  :end_user_id=>"6776-278654-6823",
#  :filename=>
#   "license-9999-234234-2342/batch-4752-164173-1238/upload-9663-680238-0901.csv",
#  :source=>nil,
#  :memo=>nil,
#  :validated_in=>nil,
#  :original_file=>"my upload.csv",
#  ...

# Make use of the convenience functions:

# GOOD - it won't request more pages than it needs
uploads.take_while { |t| ... }

# NOT SO GOOD - using select like this forces every page to be fetched
uploads.select { |t| ... }

# PRETTY AWESOME - using Enumerable#lazy to postpone filtering
uploads.lazy.select { |t| /\.csv$/ === t[:original_file] }.first 5

# Just get all the uploads:
uploads.to_a

Methods

exchange_access_key_for_jwt

NameRequiredTypeValueDescription
access_key_idtruestringAccess Key generated in app
expires_innumber43200 (default)Sets an expiration (in seconds)
secret_access_keytruestringSecret Access Key generated in app

Response: FlatfileApi::Response

download_an_upload

NameRequiredTypeValueDescription
batch_idtruestringA valid UUID
typetruestringEnum: original, processedFile to download

Response: FlatfileApi::Response

delete_an_upload

NameRequiredTypeValueDescription
batch_idtruestringA valid UUID

Response: FlatfileApi::Response

bulk_delete_uploads

NameRequiredTypeValueDescription
older_than_quantitytruestring
older_than_unittruestringEnum: minute, hour, day, week, month
send_emailtruestringEnum: true, false
team_idtruestring

Response: FlatfileApi::Response

list_workspace_uploads

NameRequiredTypeValueDescription
end_user_idstringValid endUserId for the Workspace
environment_idstringValid environmentId for the Workspace
license_keytruestringA valid licenseKey for the Workspace
searchstringSearches fileName, originalFile, memo
skipnumber0 (default)The rows to skip before listing
takenumber50 (default)The maximum number of rows to return
workspace_idstringValid workspaceId for the Workspace

Response: FlatfileApi::PaginatedResponse

file_upload_meta_data

NameRequiredTypeValueDescription
batch_idtruestringA valid UUID

Response: FlatfileApi::Response

sheet_name_for_file_upload

NameRequiredTypeValueDescription
license_keystringA valid licenseKey for the Workspace
upload_idtruestringA valid UUID

Response: FlatfileApi::Response

records_for_file_upload

NameRequiredTypeValueDescription
batch_idtruestringA valid UUID
created_at_end_datestringISO 8601The maximum createdAt date to return
created_at_start_datestringISO 8601The minimum createdAt date to return
deletedstringEnum: true, t, y, false, f, nReturn only deleted rows
skipnumber0 (default)The rows to skip before listing
takenumber50 (default)The maximum number of rows to return
updated_at_end_datestringISO 8601The maximum updatedAt date to return
updated_at_start_datestringISO 8601The minimum updatedAt date to return
validstringEnum: true, t, y, false, f, nReturn only valid rows

Response: FlatfileApi::PaginatedResponse

upload_to_workspace_sheet

NameRequiredTypeValueDescription
sheet_idtruestringA valid UUID
workspace_idtruestringA valid UUID

Response: FlatfileApi::Response

fetch_workspace_sheet_records

NameRequiredTypeValueDescription
filterstringEnum: review, dismissed, acceptedReturn only the filtered rows
merge_idstring
nestedboolean
record_idsstring[]
sheet_idtruestringA valid UUID
skipnumber0 (default)The rows to skip before listing
takenumber50 (default)The maximum number of rows to return
validstringEnum: true, t, y, false, f, nReturn only valid rows
workspace_idtruestringA valid UUID

Response: FlatfileApi::PaginatedResponse

list_team_workspaces

NameRequiredTypeValueDescription
environment_idstringValid environmentId for the Workspace
skipnumber0 (default)The rows to skip before listing
takenumber50 (default)The maximum number of rows to return
team_idtruestring

Response: FlatfileApi::PaginatedResponse

detail_workspace

NameRequiredTypeValueDescription
workspace_idtruestringA valid UUID

Response: FlatfileApi::Response

invite_workspace_collaborator

NameRequiredTypeValueDescription
emailtruestringEmail address of invited collaborator
team_idtruestring
workspace_idtruestringA valid UUID

Response: FlatfileApi::Response

list_workspace_invitations

NameRequiredTypeValueDescription
team_idtruestring
workspace_idtruestringA valid UUID

Response: FlatfileApi::Response

list_workspace_collaborators

NameRequiredTypeValueDescription
team_idtruestring
workspace_idtruestringA valid UUID

Response: FlatfileApi::Response

revoke_workspace_invitation

NameRequiredTypeValueDescription
emailtruestringEmail address of invited collaborator
team_idtruestring
workspace_idtruestringA valid UUID

Response: FlatfileApi::Response

remove_workspace_collaborator

NameRequiredTypeValueDescription
emailtruestringEmail address of collaborator
team_idtruestring
user_idtruestring
workspace_idtruestringA valid UUID

Response: FlatfileApi::Response

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/cyclotron3k/flatfile_api.

FAQs

Package last updated on 07 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc