pinata 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a84b659394d56f045dd4fffac52e0ad1d3815b975615212db80a59a2bc07b0d
4
- data.tar.gz: b50df70b4d0308360fbc101a3eeb9f79431bffa938b473afe8b2f4c068d7b743
3
+ metadata.gz: 341660ad2f2ed148c9e3a9d7a79344253888aa027a35722c435be98b3b4e905d
4
+ data.tar.gz: e931d31a5b993c2816a5fde7f6df89f04d0a6cc661abb8664403bffdfa111924
5
5
  SHA512:
6
- metadata.gz: 0c5607fa24d197b1b7885bcc65a0d63408a014d61ada52495adc8d7d2988aa9c197530e0f83e6405dbf249e551b69d24cf74615a30093b24422de3edaa0afc77
7
- data.tar.gz: ece6021ad63d6853e189777eb8ed6556534a8f3c4f8fec746c97a98447f132119853a60057d367bc1c6f17bdc30266550bef5ef79d216f6d0864b1410e559b4c
6
+ metadata.gz: 40a983ad8e8f10c626448ac3cc8b9d33f68f6884b17144b69029aef2bacd4b1c8d3410648c9d7965cc922902386172c81d8dfd53cf93b874b6dc7a22d8e7d9db
7
+ data.tar.gz: f519fbfc5365c9ed40aaf6f5cc12cacc3f3698732be980a0775e7236e5d91cab92479344e6f727f4347e2c0d6b1d2d3e454e40e9b836518ac3dc0eaf4c188c0f
@@ -2,10 +2,12 @@
2
2
 
3
3
  module Pinata
4
4
  class FilesResource < Resource
5
- def upload(file:, name: nil, mime_type: nil, metadata: nil)
5
+ def upload(file:, group_id: nil, name: nil, mime_type: nil, metadata: nil)
6
+ validate(file: file)
6
7
  mime_type ||= Marcel::MimeType.for(file)
7
8
  payload = {file: Faraday::UploadIO.new(file, mime_type)}
8
9
  payload[:name] = name unless name.nil?
10
+ payload[:group_id] = group_id unless group_id.nil?
9
11
  payload[:keyvalues] = metadata unless metadata.nil?
10
12
  File.new upload_post_request("files", body: payload,
11
13
  headers: {"Content-Type" => "multipart/form-data"}).body["data"]
@@ -38,5 +40,9 @@ module Pinata
38
40
  def delete(file_id:)
39
41
  File.new api_delete_request("files/#{file_id}").body.dig("data")
40
42
  end
43
+
44
+ def validate(file:)
45
+ raise ArgumentError, "`file` is required" if file.nil?
46
+ end
41
47
  end
42
48
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pinata
4
- VERSION = "1.0.4"
4
+ VERSION = "1.0.5"
5
5
  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.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Onyx Mueller
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-25 00:00:00.000000000 Z
11
+ date: 2025-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -87,7 +87,7 @@ metadata:
87
87
  homepage_uri: https://github.com/onyxmueller/pinata-ruby
88
88
  source_code_uri: https://github.com/onyxmueller/pinata-ruby
89
89
  changelog_uri: https://github.com/onyxmueller/pinata-ruby/changelog.md
90
- post_install_message:
90
+ post_install_message:
91
91
  rdoc_options: []
92
92
  require_paths:
93
93
  - lib
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  version: '0'
104
104
  requirements: []
105
105
  rubygems_version: 3.4.19
106
- signing_key:
106
+ signing_key:
107
107
  specification_version: 4
108
108
  summary: Ruby bindings for the Pinata API
109
109
  test_files: []