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

mojfile-uploader-api-client

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mojfile-uploader-api-client

  • 0.8
  • Rubygems
  • Socket score

Version published
Maintainers
2
Created
Source

Build
Status

mojfile-uploader-api-client

An API client for mojfile-uploader

Please refer to the above project if you want to build your own client around the API.

Configuration

In your project, create an initializer with the following:

MojFileUploaderApiClient::HttpClient.configure do |client|
  client.base_url = 'http://localhost:3003' # mandatory
  client.options = {} # optional - supports :headers, :verify_ssl, :open_timeout, :read_timeout
end

Operations

Add a file

When a previous collection reference is known:
MojFileUploaderApiClient.add_file(title: 'test', filename: 'test.txt', data: 'bla bla bla', collection_ref: 'a45c556f-a628-41d3-8c29-351f84e63757')
=> {:collection=>"a45c556f-a628-41d3-8c29-351f84e63757", :key=>"7c6aca2c-eb7a-4194-8166-9fd6ac82127b.test.txt"}

With a folder name:

MojFileUploaderApiClient.add_file(folder: 'subfolder', title: 'test', filename: 'test.txt', data: 'bla bla bla', collection_ref: 'a45c556f-a628-41d3-8c29-351f84e63757')
=> {:collection=>"a45c556f-a628-41d3-8c29-351f84e63757", :folder=>"subfolder", :key=>"7c6aca2c-eb7a-4194-8166-9fd6ac82127b.test.txt"}

Or you can use the AddFile client directly:

MojFileUploaderApiClient::AddFile.new(title: 'test', filename: 'test.txt', data: 'bla bla bla', collection_ref: 'a45c556f-a628-41d3-8c29-351f84e63757').call

=> #<MojFileUploaderApiClient::Response:0x007fe4e5c85ce0
 @body={:collection=>"a45c556f-a628-41d3-8c29-351f84e63757", :key=>"7c6aca2c-eb7a-4194-8166-9fd6ac82127b.test.txt"},
 @code=200>
No previous collection reference (will create a new one):
MojFileUploaderApiClient.add_file(title: 'test', filename: 'test.txt', data: 'bla bla bla')
=> {:collection=>"741635f7-488a-49cc-a3f1-9ee38795e28e", :key=>"0543a21d-e884-4076-89be-41cc09b00da1.test.txt"}

Or you can use the AddFile client directly:

MojFileUploaderApiClient::AddFile.new(title: 'test', filename: 'test.txt', data: 'bla bla bla').call

=> #<MojFileUploaderApiClient::Response:0x007fe4e5b8cc58
 @body={:collection=>"741635f7-488a-49cc-a3f1-9ee38795e28e", :key=>"0543a21d-e884-4076-89be-41cc09b00da1.test.txt"},
 @code=200>

Delete a file

MojFileUploaderApiClient.delete_file(collection_ref: 'a45c556f-a628-41d3-8c29-351f84e63757', filename: 'test1.txt')
=> RequestError

With a folder:

MojFileUploaderApiClient.delete_file(collection_ref: 'a45c556f-a628-41d3-8c29-351f84e63757', folder: 'subfolder', filename: 'test1.txt')
=> RequestError

Or you can use the DeleteFile client directly:

MojFileUploaderApiClient::DeleteFile.new(collection_ref: 'a45c556f-a628-41d3-8c29-351f84e63757', filename: 'test1.txt').call
=> #<MojFileUploaderApiClient::Response:0x007fe4e59c8098 @body={:body_parser_error=>"743: unexpected token at ''"}, @code=204>

List files

MojFileUploaderApiClient.list_files(collection_ref: 'a45c556f-a628-41d3-8c29-351f84e63757')
=> {:collection=>"a45c556f-a628-41d3-8c29-351f84e63757",
    :files=>[{:key=>"a45c556f-a628-41d3-8c29-351f84e63757/test1.txt", :title=>"test1.txt", :last_modified=>"2016-11-30T15:30:52.000Z"}]}

With a folder:

MojFileUploaderApiClient.list_files(collection_ref: 'a45c556f-a628-41d3-8c29-351f84e63757', folder: 'subfolder')
=> {:collection=>"a45c556f-a628-41d3-8c29-351f84e63757", :folder=>"subfolder",
    :files=>[{:key=>"a45c556f-a628-41d3-8c29-351f84e63757/subfolder/test1.txt", :title=>"test1.txt", :last_modified=>"2016-11-30T15:30:52.000Z"}]}

Or you can use the ListFiles client directly:

MojFileUploaderApiClient::ListFiles.new(collection_ref: 'a45c556f-a628-41d3-8c29-351f84e63757').call
=> #<MojFileUploaderApiClient::Response:0x007fe4e5ac91e0
 @body=
  {:collection=>"a45c556f-a628-41d3-8c29-351f84e63757",
   :files=>[{:key=>"a45c556f-a628-41d3-8c29-351f84e63757/test1.txt", :title=>"test1.txt", :last_modified=>"2016-11-30T15:30:52.000Z"}]}
 @code=200>

Contributing

Fork, then clone the repo:

git clone git@github.com:your-username/mojfile-uploader-api-client.git

Make sure the tests pass:

bundle exec rake

Make your change. Add specs for your change. Make the specs pass:

bundle exec rake

Push to your fork and submit a pull request.

Some things that will increase the chance that your pull request is accepted:

  • Write specs.
  • Make sure you don’t have any mutants (part of total test suite).
  • Write a good commit message.

License

Released under the MIT License. Copyright (c) 2016 Ministry of Justice.

FAQs

Package last updated on 09 May 2017

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