pinata 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/LICENSE.txt +21 -0
- data/README.md +109 -0
- data/Rakefile +16 -0
- data/lib/pinata/client.rb +60 -0
- data/lib/pinata/collection.rb +28 -0
- data/lib/pinata/error.rb +5 -0
- data/lib/pinata/object.rb +21 -0
- data/lib/pinata/objects/file.rb +6 -0
- data/lib/pinata/resource.rb +63 -0
- data/lib/pinata/resources/authentication.rb +9 -0
- data/lib/pinata/resources/files.rb +34 -0
- data/lib/pinata/version.rb +5 -0
- data/lib/pinata.rb +21 -0
- data/pinata.gemspec +46 -0
- data/sig/pinata.rbs +4 -0
- metadata +107 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4b58adb3eac2c345d9c010d8dda02f38e7a8963501dc951e8e211ae506862ad6
|
4
|
+
data.tar.gz: 3e63495aae0b3713ed43b3194e09273ebb3b1f8a853b5dedd25e736f7a2485d1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8d75e436576b230350bbe0a0f3d19304ecebe1ff6ad336aa0e6d0960e46cc0b8a25e03900322a5b6f97cc4856dc3841dad84155170179ac249c74e9444d7c942
|
7
|
+
data.tar.gz: 5e01a7b68ebe411720ebdd969a01088894d7d29e8827981df4dbc2bc95cf4ab3778387896a2a0a15fd94aa16d1c56995ee8f33dd265355ef9668f259780a4b72
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.2.3
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at contact@onyxmueller.net. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Onyx Mueller
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
# Pinata
|
2
|
+
|
3
|
+
[![Build Status](https://github.com/onyxmueller/pinata-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/onyxmueller/pinata-ruby/actions/workflows/build.yml)
|
4
|
+
|
5
|
+
![header](https://docs.mypinata.cloud/ipfs/QmP9PGe3PdUqmsq8xY4sEW3qgdXx4WT9ictTWCb3qyzz3s?img-format=webp)
|
6
|
+
|
7
|
+
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.
|
8
|
+
|
9
|
+
## Documentation
|
10
|
+
|
11
|
+
See the [Pinata API docs](https://docs.pinata.cloud/api-reference).
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```sh
|
18
|
+
gem 'pinata', github: "onyxmueller/pinata-ruby"
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
```sh
|
24
|
+
bundle
|
25
|
+
```
|
26
|
+
|
27
|
+
Or install it yourself as:
|
28
|
+
|
29
|
+
```sh
|
30
|
+
gem install pinata
|
31
|
+
```
|
32
|
+
|
33
|
+
### Requirements
|
34
|
+
|
35
|
+
- Ruby 2.6+.
|
36
|
+
|
37
|
+
## Usage
|
38
|
+
|
39
|
+
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](https://app.pinata.cloud/developers/api-keys).
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
client = Pinata::Client.new(jwt_key: ENV["PINATA_JWT"])
|
43
|
+
```
|
44
|
+
|
45
|
+
## Resources
|
46
|
+
|
47
|
+
The gem maps as closely as we can to the Pinata API so you can easily convert API examples to gem code.
|
48
|
+
|
49
|
+
Responses are created as objects like `Pinata::File`. They're built using [OpenStruct](https://github.com/ruby/ostruct) so you can easily access data in a Ruby-ish way.
|
50
|
+
|
51
|
+
### Pagination
|
52
|
+
|
53
|
+
`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.
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
results = client.files.list
|
57
|
+
#=> Pinata::Collection
|
58
|
+
|
59
|
+
results.data.size
|
60
|
+
#=> 48
|
61
|
+
|
62
|
+
results.data
|
63
|
+
#=> [#<Pinata::File>, #<Pinata::File>]
|
64
|
+
|
65
|
+
results.next_page_token
|
66
|
+
#=> "MDE5MzJjNzctMDg2Ny03ZTdhLWE2ZDEtMDRhZWRlZDNjMWI5"
|
67
|
+
|
68
|
+
# Retrieve the next page
|
69
|
+
client.files.list(pageToken: "MDE5MzJjNzctMDg2Ny03ZTdhLWE2ZDEtMDRhZWRlZDNjMWI5")
|
70
|
+
#=> Pinata::Collection
|
71
|
+
```
|
72
|
+
|
73
|
+
### Authentication
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
client.authentication.test
|
77
|
+
```
|
78
|
+
|
79
|
+
### Files
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
client.files.upload(file: "/path/to/file")
|
83
|
+
client.files.list
|
84
|
+
client.files.list("metadata[key]": "value")
|
85
|
+
client.files.update(file_id: "thefileid", "name": "thenameoffile")
|
86
|
+
client.files.sign("gateway": "yourgatewaydomain", "file_cid": "thefilecid", "expires": 500000)
|
87
|
+
```
|
88
|
+
|
89
|
+
## Development
|
90
|
+
|
91
|
+
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.
|
92
|
+
|
93
|
+
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](https://rubygems.org).
|
94
|
+
|
95
|
+
## Contributing
|
96
|
+
|
97
|
+
1. Fork it ( [https://github.com/onyxmueller/pinata-ruby/fork](https://github.com/onyxmueller/pinata-ruby/fork) )
|
98
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
99
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
100
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
101
|
+
5. Create a new Pull Request
|
102
|
+
|
103
|
+
## License
|
104
|
+
|
105
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
106
|
+
|
107
|
+
## Code of Conduct
|
108
|
+
|
109
|
+
Everyone interacting in the Pinata project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/onyxmueller/pinata-ruby/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
task default: %i[standard test]
|
7
|
+
|
8
|
+
Rake::TestTask.new(:test) do |t|
|
9
|
+
t.libs << "test"
|
10
|
+
t.libs << "lib"
|
11
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
12
|
+
end
|
13
|
+
|
14
|
+
task :standard do
|
15
|
+
exec "standardrb"
|
16
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pinata
|
4
|
+
class Client
|
5
|
+
API_VERSION = "v3"
|
6
|
+
BASE_DOMAIN = "pinata.cloud"
|
7
|
+
API_BASE_URL = "https://api.#{BASE_DOMAIN}/"
|
8
|
+
API_URL = "#{API_BASE_URL}#{API_VERSION}/"
|
9
|
+
UPLOADS_URL = "https://uploads.#{BASE_DOMAIN}/#{API_VERSION}/"
|
10
|
+
|
11
|
+
attr_reader :pinata_jwt, :adapter
|
12
|
+
|
13
|
+
def initialize(pinata_jwt:, adapter: Faraday.default_adapter, stubs: nil)
|
14
|
+
@pinata_jwt = pinata_jwt
|
15
|
+
@adapter = adapter
|
16
|
+
|
17
|
+
# Test stubs for requests
|
18
|
+
@stubs = stubs
|
19
|
+
end
|
20
|
+
|
21
|
+
def authentication
|
22
|
+
AuthenticationResource.new(self)
|
23
|
+
end
|
24
|
+
|
25
|
+
def files
|
26
|
+
FilesResource.new(self)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_connection
|
30
|
+
@test_connection ||= Faraday.new(url: API_BASE_URL) do |conn|
|
31
|
+
conn.request :authorization, :Bearer, pinata_jwt
|
32
|
+
conn.response :json, content_type: "application/json"
|
33
|
+
conn.adapter adapter, @stubs
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def upload_connection
|
38
|
+
@upload_connection ||= Faraday.new(url: UPLOADS_URL) do |conn|
|
39
|
+
conn.request :authorization, :Bearer, pinata_jwt
|
40
|
+
conn.request :multipart
|
41
|
+
conn.request :json
|
42
|
+
conn.response :json, content_type: "application/json"
|
43
|
+
conn.adapter adapter, @stubs
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def api_connection
|
48
|
+
@api_connection ||= Faraday.new(url: API_URL) do |conn|
|
49
|
+
conn.request :authorization, :Bearer, pinata_jwt
|
50
|
+
conn.request :json
|
51
|
+
conn.response :json, content_type: "application/json"
|
52
|
+
conn.adapter adapter, @stubs
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def inspect
|
57
|
+
"#<Pinata::Client>"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pinata
|
4
|
+
class Collection
|
5
|
+
attr_reader :data, :next_page_token
|
6
|
+
|
7
|
+
def self.from_response(response, key:, type:)
|
8
|
+
body = response.body
|
9
|
+
new(
|
10
|
+
data: body["data"][key].map { |attrs| type.new(attrs) },
|
11
|
+
next_page_token: body.dig("data", "next_page_token")
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(data:, next_page_token:)
|
16
|
+
@data = data
|
17
|
+
@next_page_token = (next_page_token.nil? || next_page_token.empty?) ? nil : next_page_token
|
18
|
+
end
|
19
|
+
|
20
|
+
def empty?
|
21
|
+
data.empty?
|
22
|
+
end
|
23
|
+
|
24
|
+
def sample
|
25
|
+
data.sample
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/pinata/error.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "ostruct"
|
4
|
+
|
5
|
+
module Pinata
|
6
|
+
class Object < OpenStruct
|
7
|
+
def initialize(attributes)
|
8
|
+
super(to_ostruct(attributes))
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_ostruct(obj)
|
12
|
+
if obj.is_a?(Hash)
|
13
|
+
OpenStruct.new(obj.transform_values { |val| to_ostruct(val) })
|
14
|
+
elsif obj.is_a?(Array)
|
15
|
+
obj.map { |o| to_ostruct(o) }
|
16
|
+
else # Assumed to be a primitive value
|
17
|
+
obj
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pinata
|
4
|
+
class Resource
|
5
|
+
attr_reader :client
|
6
|
+
|
7
|
+
def initialize(client)
|
8
|
+
@client = client
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def test_get_request(url)
|
14
|
+
handle_response client.test_connection.get(url)
|
15
|
+
end
|
16
|
+
|
17
|
+
def upload_post_request(url, body:, headers: {})
|
18
|
+
handle_response client.upload_connection.post(url, body, headers)
|
19
|
+
end
|
20
|
+
|
21
|
+
def api_get_request(url, params: {}, headers: {})
|
22
|
+
handle_response client.api_connection.get(url, params, headers)
|
23
|
+
end
|
24
|
+
|
25
|
+
def api_post_request(url, body:, headers: {})
|
26
|
+
handle_response client.api_connection.post(url, body, headers)
|
27
|
+
end
|
28
|
+
|
29
|
+
def api_patch_request(url, body:, headers: {})
|
30
|
+
handle_response client.api_connection.patch(url, body, headers)
|
31
|
+
end
|
32
|
+
|
33
|
+
def api_put_request(url, body:, headers: {})
|
34
|
+
handle_response client.api_connection.put(url, body, headers)
|
35
|
+
end
|
36
|
+
|
37
|
+
def api_delete_request(url, params: {}, headers: {})
|
38
|
+
handle_response client.api_connection.delete(url, params, headers)
|
39
|
+
end
|
40
|
+
|
41
|
+
def handle_response(response)
|
42
|
+
case response.status
|
43
|
+
when 400
|
44
|
+
raise Error, "Your request was malformed. #{response.body["error"]}"
|
45
|
+
when 401
|
46
|
+
raise Error, "You did not supply valid authentication credentials. #{response.body["error"]}"
|
47
|
+
when 403
|
48
|
+
raise Error, "You are not allowed to perform that action. #{response.body["error"]}"
|
49
|
+
when 404
|
50
|
+
raise Error, "No results were found for your request. #{response.body["error"]}"
|
51
|
+
when 429
|
52
|
+
raise Error, "Your request exceeded the API rate limit. #{response.body["error"]}"
|
53
|
+
when 500
|
54
|
+
raise Error, "We were unable to perform the request due to server-side problems. #{response.body["error"]}"
|
55
|
+
when 503
|
56
|
+
raise Error,
|
57
|
+
"You have been rate limited for sending more than 20 requests per second. #{response.body["error"]}"
|
58
|
+
end
|
59
|
+
|
60
|
+
response
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pinata
|
4
|
+
class FilesResource < Resource
|
5
|
+
def upload(file:, name: nil, mime_type: nil, metadata: nil)
|
6
|
+
mime_type ||= Marcel::MimeType.for(file)
|
7
|
+
payload = {file: Faraday::UploadIO.new(file, mime_type)}
|
8
|
+
payload[:name] = name unless name.nil?
|
9
|
+
payload[:keyvalues] = metadata unless metadata.nil?
|
10
|
+
File.new upload_post_request("files", body: payload,
|
11
|
+
headers: {"Content-Type" => "multipart/form-data"}).body["data"]
|
12
|
+
end
|
13
|
+
|
14
|
+
def list(**params)
|
15
|
+
response = api_get_request("files", params: params)
|
16
|
+
Collection.from_response(response, key: "files", type: File)
|
17
|
+
end
|
18
|
+
|
19
|
+
def sign(gateway:, file_cid:, expires:, date: Time.now.to_i,
|
20
|
+
url_method: "GET")
|
21
|
+
payload = {
|
22
|
+
url: "https://#{gateway}/files/#{file_cid}",
|
23
|
+
date: date,
|
24
|
+
expires: expires,
|
25
|
+
method: url_method
|
26
|
+
}
|
27
|
+
api_post_request("files/sign", body: payload).body["data"]
|
28
|
+
end
|
29
|
+
|
30
|
+
def update(file_id:, **attributes)
|
31
|
+
File.new api_put_request("files/#{file_id}", body: attributes).body["data"]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/pinata.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Pinata Ruby bindings
|
4
|
+
# API spec at https://docs.pinata.cloud/api-reference/
|
5
|
+
require "faraday"
|
6
|
+
require "faraday/multipart"
|
7
|
+
require "marcel"
|
8
|
+
require "pinata/version"
|
9
|
+
|
10
|
+
module Pinata
|
11
|
+
autoload :Client, "pinata/client"
|
12
|
+
autoload :Collection, "pinata/collection"
|
13
|
+
autoload :Error, "pinata/error"
|
14
|
+
autoload :Resource, "pinata/resource"
|
15
|
+
autoload :Object, "pinata/object"
|
16
|
+
|
17
|
+
autoload :AuthenticationResource, "pinata/resources/authentication"
|
18
|
+
autoload :FilesResource, "pinata/resources/files"
|
19
|
+
|
20
|
+
autoload :File, "pinata/objects/file"
|
21
|
+
end
|
data/pinata.gemspec
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "pinata/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "pinata"
|
9
|
+
spec.version = Pinata::VERSION
|
10
|
+
spec.authors = ["Onyx Mueller"]
|
11
|
+
spec.email = ["contact@onyxmueller.net"]
|
12
|
+
|
13
|
+
spec.summary = "Ruby bindings for the Pinata API"
|
14
|
+
spec.description = "Ruby bindings for the Pinata API. More info about Pinata can be found here: https://docs.pinata.cloud/quickstart"
|
15
|
+
spec.homepage = "https://github.com/onyxmueller/pinata-ruby"
|
16
|
+
spec.license = "MIT"
|
17
|
+
spec.required_ruby_version = ">= 2.6.0"
|
18
|
+
|
19
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
20
|
+
|
21
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
22
|
+
spec.metadata["source_code_uri"] = "https://github.com/onyxmueller/pinata-ruby"
|
23
|
+
spec.metadata["changelog_uri"] = "https://github.com/onyxmueller/pinata-ruby/changelog.md"
|
24
|
+
|
25
|
+
# Specify which files should be added to the gem when it is released.
|
26
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
27
|
+
spec.files = Dir.chdir(__dir__) do
|
28
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
29
|
+
(File.expand_path(f) == __FILE__) ||
|
30
|
+
f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
spec.bindir = "exe"
|
34
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
35
|
+
spec.require_paths = ["lib"]
|
36
|
+
|
37
|
+
# Uncomment to register a new dependency of your gem
|
38
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
39
|
+
|
40
|
+
# For more information and examples about making a new gem, check out our
|
41
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
42
|
+
|
43
|
+
spec.add_dependency "faraday", "~> 2.12"
|
44
|
+
spec.add_dependency "faraday-multipart", "~> 1.0.4"
|
45
|
+
spec.add_dependency "marcel", "~> 1.0.4"
|
46
|
+
end
|
data/sig/pinata.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pinata
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Onyx Mueller
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-11-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.12'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday-multipart
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.4
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.0.4
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: marcel
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.0.4
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.4
|
55
|
+
description: 'Ruby bindings for the Pinata API. More info about Pinata can be found
|
56
|
+
here: https://docs.pinata.cloud/quickstart'
|
57
|
+
email:
|
58
|
+
- contact@onyxmueller.net
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".ruby-version"
|
64
|
+
- CHANGELOG.md
|
65
|
+
- CODE_OF_CONDUCT.md
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- lib/pinata.rb
|
70
|
+
- lib/pinata/client.rb
|
71
|
+
- lib/pinata/collection.rb
|
72
|
+
- lib/pinata/error.rb
|
73
|
+
- lib/pinata/object.rb
|
74
|
+
- lib/pinata/objects/file.rb
|
75
|
+
- lib/pinata/resource.rb
|
76
|
+
- lib/pinata/resources/authentication.rb
|
77
|
+
- lib/pinata/resources/files.rb
|
78
|
+
- lib/pinata/version.rb
|
79
|
+
- pinata.gemspec
|
80
|
+
- sig/pinata.rbs
|
81
|
+
homepage: https://github.com/onyxmueller/pinata-ruby
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
metadata:
|
85
|
+
homepage_uri: https://github.com/onyxmueller/pinata-ruby
|
86
|
+
source_code_uri: https://github.com/onyxmueller/pinata-ruby
|
87
|
+
changelog_uri: https://github.com/onyxmueller/pinata-ruby/changelog.md
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.6.0
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubygems_version: 3.4.19
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: Ruby bindings for the Pinata API
|
107
|
+
test_files: []
|