Project

pinata

0.0
The project is in a healthy, maintained state
Ruby bindings for the Pinata API. More info about Pinata can be found here: https://docs.pinata.cloud/quickstart
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 2.12
~> 1.0.4
 Project Readme

Pinata

Gem Version Build Status

header

The Pinata Ruby library provides convenient access to the Pinata API from applications written in the Ruby language. It includes a pre-defined set of classes for API resources that initialize themselves dynamically from API responses.

Documentation

See the Pinata API docs.

Installation

Add this line to your application's Gemfile:

    gem 'pinata', github: "onyxmueller/pinata-ruby"

And then execute:

    bundle

Or install it yourself as:

    gem install pinata

Requirements

  • Ruby 2.6+.

Usage

To access the API, you'll need to create a Pinata::Client and pass in your API key. You can find your API key at https://app.pinata.cloud/developers/api-keys.

    client = Pinata::Client.new(jwt_key: ENV["PINATA_JWT"])

Resources

The gem maps as closely as we can to the Pinata API so you can easily convert API examples to gem code.

Responses are created as objects like Pinata::File. They're built using OpenStruct so you can easily access data in a Ruby-ish way.

Pagination

List endpoints return pages of results. The result object will have a data key to access the results, as well as metadata like next_page_token for retrieving the next page.

results = client.files.list
#=> Pinata::Collection

results.data.size
#=> 48

results.data
#=> [#<Pinata::File>, #<Pinata::File>]

results.next_page_token
#=> "MDE5MzJjNzctMDg2Ny03ZTdhLWE2ZDEtMDRhZWRlZDNjMWI5"

# Retrieve the next page
client.files.list(pageToken: "MDE5MzJjNzctMDg2Ny03ZTdhLWE2ZDEtMDRhZWRlZDNjMWI5")
#=> Pinata::Collection

Authentication

client.authentication.test

Files

client.files.upload(file: "/path/to/file")
client.files.list
client.files.list("metadata[key]": "value")
client.files.get(file_id: "1234567890")
client.files.sign("gateway": "yourgatewaydomain", "file_cid": "thefilecid", "expires": 500000)
client.files.update(file_id: "thefilesid", "name": "thenameoffile")
client.files.delete(file_id: "1234567890")

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

  1. Fork it ( https://github.com/onyxmueller/pinata-ruby/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Pinata project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.