pinata 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba75b73272ea6aa069b6e0611646d16bd912007d3c1301cf642261b32171788d
4
- data.tar.gz: c97be242f95c38e6c8981ed07bc7b5ef87a34d11498bc0a25ca585ef9d2c17ee
3
+ metadata.gz: 0a84b659394d56f045dd4fffac52e0ad1d3815b975615212db80a59a2bc07b0d
4
+ data.tar.gz: b50df70b4d0308360fbc101a3eeb9f79431bffa938b473afe8b2f4c068d7b743
5
5
  SHA512:
6
- metadata.gz: 7f3d95309e9f692bf1b027d9936f0c8ce5243570ab7f3e2c92c0c1eacf9acc593405733037cf138125a32b52979eaff1c362cf622b78a83f7f86c4eae394ca82
7
- data.tar.gz: d3c0da1b275300a2d40f6c54bc0c67f7b4e6b864506c3ea576605e28a73c29295466e7299bf562fde06302c16fd21e6917163bcbaabbc04fa7544da3a890f8c6
6
+ metadata.gz: 0c5607fa24d197b1b7885bcc65a0d63408a014d61ada52495adc8d7d2988aa9c197530e0f83e6405dbf249e551b69d24cf74615a30093b24422de3edaa0afc77
7
+ data.tar.gz: ece6021ad63d6853e189777eb8ed6556534a8f3c4f8fec746c97a98447f132119853a60057d367bc1c6f17bdc30266550bef5ef79d216f6d0864b1410e559b4c
data/README.md CHANGED
@@ -89,6 +89,18 @@ client.files.update(file_id: "thefilesid", "name": "thenameoffile")
89
89
  client.files.delete(file_id: "1234567890")
90
90
  ```
91
91
 
92
+ ### Groups
93
+
94
+ ```ruby
95
+ client.groups.create({})
96
+ client.groups.get(group_id: "id")
97
+ client.groups.list
98
+ client.groups.add_file(group_id: "id", file_id: "id")
99
+ client.groups.remove_file(group_id: "id", file_id: "id")
100
+ client.groups.update(group_id: "id", {})
101
+ client.groups.delete(group_id: "id")
102
+ ```
103
+
92
104
  ## Development
93
105
 
94
106
  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.
data/lib/pinata/client.rb CHANGED
@@ -26,6 +26,10 @@ module Pinata
26
26
  FilesResource.new(self)
27
27
  end
28
28
 
29
+ def groups
30
+ GroupsResource.new(self)
31
+ end
32
+
29
33
  def test_connection
30
34
  @test_connection ||= Faraday.new(url: API_BASE_URL) do |conn|
31
35
  conn.request :authorization, :Bearer, pinata_jwt
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pinata
4
+ class Group < Object
5
+ end
6
+ end
@@ -30,7 +30,7 @@ module Pinata
30
30
  handle_response client.api_connection.patch(url, body, headers)
31
31
  end
32
32
 
33
- def api_put_request(url, body:, headers: {})
33
+ def api_put_request(url, body: {}, headers: {})
34
34
  handle_response client.api_connection.put(url, body, headers)
35
35
  end
36
36
 
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pinata
4
+ class GroupsResource < Resource
5
+ def create(name:, is_public: false)
6
+ payload = {
7
+ name: name,
8
+ is_public: is_public
9
+ }
10
+ Group.new api_post_request("files/groups", body: payload).body["data"]
11
+ end
12
+
13
+ def get(group_id:)
14
+ Group.new api_get_request("files/groups/#{group_id}").body.dig("data")
15
+ end
16
+
17
+ def list(**params)
18
+ response = api_get_request("files/groups", params: params)
19
+ Collection.from_response(response, key: "groups", type: Group)
20
+ end
21
+
22
+ def add_file(group_id:, file_id:)
23
+ Group.new api_put_request("files/groups/#{group_id}/ids/#{file_id}").body["data"]
24
+ end
25
+
26
+ def remove_file(group_id:, file_id:)
27
+ Group.new api_delete_request("files/groups/#{group_id}/ids/#{file_id}").body["data"]
28
+ end
29
+
30
+ def update(group_id:, **attributes)
31
+ Group.new api_put_request("files/groups/#{group_id}", body: attributes).body["data"]
32
+ end
33
+
34
+ def delete(group_id:)
35
+ Group.new api_delete_request("files/groups/#{group_id}").body.dig("data")
36
+ end
37
+ end
38
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pinata
4
- VERSION = "1.0.3"
4
+ VERSION = "1.0.4"
5
5
  end
data/lib/pinata.rb CHANGED
@@ -16,6 +16,8 @@ module Pinata
16
16
 
17
17
  autoload :AuthenticationResource, "pinata/resources/authentication"
18
18
  autoload :FilesResource, "pinata/resources/files"
19
+ autoload :GroupsResource, "pinata/resources/groups"
19
20
 
20
21
  autoload :File, "pinata/objects/file"
22
+ autoload :Group, "pinata/objects/group"
21
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pinata
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Onyx Mueller
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-20 00:00:00.000000000 Z
11
+ date: 2024-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -72,9 +72,11 @@ files:
72
72
  - lib/pinata/error.rb
73
73
  - lib/pinata/object.rb
74
74
  - lib/pinata/objects/file.rb
75
+ - lib/pinata/objects/group.rb
75
76
  - lib/pinata/resource.rb
76
77
  - lib/pinata/resources/authentication.rb
77
78
  - lib/pinata/resources/files.rb
79
+ - lib/pinata/resources/groups.rb
78
80
  - lib/pinata/version.rb
79
81
  - pinata.gemspec
80
82
  - sig/pinata.rbs