muffin_man 2.4.9 → 2.4.11

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: 9bf958ab9a38a6e686f7c2439c1bfe9c3e3ac1264b4d809ca569ae83fc93edab
4
- data.tar.gz: f98710b2d26bc4c10672a037025362812186f715e8e1c8cce6b961424581daed
3
+ metadata.gz: 33f0611029142ad77dfc45fd3554b68b0579c9ab5aa9aec1764e9e21a208ded2
4
+ data.tar.gz: 378875142894a576c71e69628786f473eb83a14f2abc94bc147eceaf0c836a81
5
5
  SHA512:
6
- metadata.gz: 0caa54a781067e8a7d9ec9ecceea77b03f606e2be9091b060b4bbd568827d65121ca03141e4065b8062e8f269d3246b8078c266fcd985464ac0aefd48237a9cf
7
- data.tar.gz: 41d32878a81281c5ae5a485fb56e39a58165ee3281f7d52e416b1bc482627ce8e3ead221815738dfba613c620b89da4a09ecba4b56ad082db394c9693e42abc3
6
+ metadata.gz: ad19739230189a856576ad94d39d41e2c058f97f962f3f718f8d634f2976cbc2b7361ad2648d68ee487f8106f626eaeb977b8adcba3a5d9657a53d59429af6c8
7
+ data.tar.gz: 17da668a051fe58d4415b76b4f2b89164ed0e9a23b634ecea84195ec249ba59081e53b85a98d041475a28f4788bad558ac5902db48033c71d558b36309c4b8f2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # 2.4.11
2
+
3
+ - Application Management API v2023-11-30 [#88](https://github.com/patterninc/muffin_man/pull/88)
4
+
5
+ # 2.4.10
6
+
7
+ - Sellers API v1 [#87](https://github.com/patterninc/muffin_man/pull/87)
8
+ - Listings API v20210801 searchListingsItem [#87](https://github.com/patterninc/muffin_man/pull/87)
9
+
1
10
  # 2.4.8
2
11
 
3
12
  - Customer Feedback v2024-06-01 [#80] (https://github.com/patterninc/muffin_man/pull/80)
data/README.md CHANGED
@@ -25,6 +25,7 @@ As of now, this gem only supports portions of the following APIs with more to co
25
25
  - `Product Pricing API v0`
26
26
  - `Reports API v2021-06-30`
27
27
  - `Solicitations API v1`
28
+ - `Sellers API v1`
28
29
  - `Tokens API v2021-03-01`
29
30
  - `Vendor Direct Fulfillment Transactions API v1`
30
31
  - `Vendor Direct Fulfillment Orders API v2021-12-28`
@@ -35,6 +36,9 @@ As of now, this gem only supports portions of the following APIs with more to co
35
36
  - `Vendor Orders API v1`
36
37
  - `Vendor Shipments API v1`
37
38
  - `Vendor Transaction Status API v1`
39
+ - `Uploads API v2020-11-01`
40
+ - `A+ API v2020-11-01`
41
+ - `Application Management API v2023-11-30`
38
42
 
39
43
  ## Installation
40
44
 
@@ -123,6 +127,18 @@ auth_code = resp['payload']['authorizationCode']
123
127
  refresh_token = MuffinMan::Lwa::AuthHelper.get_refresh_token(CLIENT_ID, CLIENT_SECRET, auth_code)
124
128
  ```
125
129
 
130
+ ### Retrieiving the access token
131
+ To retrieve the access token, you can use the LWA helper:
132
+ ```ruby
133
+ access_token = MuffinMan::Lwa::AuthHelper.get_access_token(scope, client_id, client_secret)
134
+ ```
135
+
136
+ ### Rotating application client secret
137
+ To rotate client secret for application
138
+ ```ruby
139
+ MuffinMan::ApplicationManagement::V20231130.rotate_application_client_secret(access_token)
140
+ ```
141
+
126
142
  ### Debugging
127
143
 
128
144
  To use Typheous' verbose mode set env variable `MUFFIN_MAN_DEBUG=true`
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MuffinMan
4
+ module AplusContent
5
+ class V20201101 < SpApiClient
6
+ # Create content document
7
+ #
8
+ # This API is used to upload A+ Content documents.
9
+ # The content document is the container for all A+ modules in a specific language.
10
+ # It is required for creating content in A+ Content Manager.
11
+ # @param marketplace_id The identifier for the marketplace where the A+ Content is published.
12
+ # @param content_document_payload The content document request payload.
13
+ # Refer to the A+ Content API documentation for more information.
14
+ # @return [Hash]
15
+ # The response from the API, which includes the signed upload URL and additional metadata.
16
+ # @raise [StandardError]
17
+ # Raises an error if the API request fails.
18
+ #
19
+ # @example
20
+ # client = MuffinMan::AplusContent::V20201101.new
21
+ # response = client.create_content_documents(
22
+ # "ATVPDKIKX0DER",
23
+ # { "contentDocument" => {
24
+ # "name" => "My Content Document",
25
+ # "contentType" => "STANDARD",
26
+ # "locale" => "en_US",
27
+ # "contentModuleList" => "< ContentModule > array"
28
+ # }
29
+ # }
30
+ # )
31
+ # puts response
32
+ def create_content_documents(marketplace_id, content_document_payload)
33
+ @local_var_path = "/aplus/2020-11-01/contentDocuments"
34
+ @query_params = { "marketplaceId" => marketplace_id }
35
+ @request_body = content_document_payload
36
+ @request_type = "POST"
37
+
38
+ call_api
39
+ end
40
+
41
+ # Create content document asin relations
42
+ #
43
+ # This API is used to associate ASINs with a content document.
44
+ # The content document is the container for all A+ modules in a specific language.
45
+ # It is required for creating content in A+ Content Manager.
46
+ # @param marketplace_id The identifier for the marketplace where the A+ Content is published.
47
+ # @param content_reference_key The unique reference key for the content document.
48
+ # @param asin_set The set of ASINs.
49
+ # @return [Hash]
50
+ # The response from the API, which includes the signed upload URL and additional metadata.
51
+ # @raise [StandardError]
52
+ # Raises an error if the API request fails.
53
+ #
54
+ # @example
55
+ # client = MuffinMan::AplusContent::V20201101.new
56
+ # response = client.post_content_document_asin_relations(
57
+ # "ATVPDKIKX0DER",
58
+ # "contentReferenceKey",
59
+ # ["B07H8QMZWV", "B07H8QMZWV"]
60
+ # )
61
+ # puts response
62
+ def post_content_document_asin_relations(marketplace_id, content_reference_key, asin_set)
63
+ @local_var_path = "/aplus/2020-11-01/contentDocuments/#{content_reference_key}/asins"
64
+ @query_params = { "marketplaceId" => marketplace_id }
65
+ @request_body = { "asinSet" => asin_set }
66
+ @request_type = "POST"
67
+
68
+ call_api
69
+ end
70
+
71
+ # validate content document asin relations
72
+ #
73
+ # This API is used to validate the content document ASINs.
74
+ # The content document is the container for all A+ modules in a specific language.
75
+ # It is required for creating content in A+ Content Manager.
76
+ # @param marketplace_id The identifier for the marketplace where the A+ Content is published.
77
+ # @param asin_set The set of ASINs.
78
+ # @param content_document_payload The content document request payload.
79
+ # Refer to the A+ Content API documentation for more information.
80
+ # @return [Hash]
81
+ # The response from the API, which includes the signed upload URL and additional metadata.
82
+ # @raise [StandardError]
83
+ # Raises an error if the API request fails.
84
+ #
85
+ # @example
86
+ # client = MuffinMan::AplusContent::V20201101.new
87
+ # response = client.validate_content_document_asin_relations(
88
+ # "ATVPDKIKX0DER",
89
+ # ["B07H8QMZWV", "B07H8QMZWV"],
90
+ # { "contentDocument" => {
91
+ # "name" => "My Content Document",
92
+ # "contentType" => "STANDARD",
93
+ # "locale" => "en_US",
94
+ # "contentModuleList" => "< ContentModule > array"
95
+ # }
96
+ # }
97
+ # )
98
+ # puts response
99
+ def validate_content_document_asin_relations(marketplace_id, asin_set, content_document_payload)
100
+ @local_var_path = "/aplus/2020-11-01/contentAsinValidations"
101
+ @query_params = { "marketplaceId" => marketplace_id, "asinSet" => asin_set.join(",") }
102
+ @request_body = content_document_payload
103
+ @request_type = "POST"
104
+
105
+ call_api
106
+ end
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MuffinMan
4
+ module ApplicationManagement
5
+ class V20231130
6
+ def self.rotate_application_client_secret(access_token)
7
+ Typhoeus.post(
8
+ "https://sellingpartnerapi-na.amazon.com/applications/2023-11-30/clientSecret",
9
+ headers: { "x-amz-access-token" => access_token }
10
+ )
11
+ end
12
+ end
13
+ end
14
+ end
@@ -65,6 +65,21 @@ module MuffinMan
65
65
  @request_type = "PATCH"
66
66
  call_api
67
67
  end
68
+
69
+ def search_listings_items(seller_id, marketplace_ids, **optional_query)
70
+ @local_var_path = "/listings/2021-08-01/items/#{seller_id}"
71
+ @marketplace_ids = marketplace_ids.is_a?(Array) ? marketplace_ids : [marketplace_ids]
72
+ @query_params = {
73
+ "marketplaceIds" => @marketplace_ids.join(",")
74
+ }
75
+ optional_query.each do |key, value|
76
+ camel_key = key.to_s.camelize(:lower).to_sym
77
+ string_value = value.is_a?(Array) ? value.join(",") : value
78
+ @query_params[camel_key] = string_value
79
+ end
80
+ @request_type = "GET"
81
+ call_api
82
+ end
68
83
  end
69
84
  end
70
85
  end
@@ -23,5 +23,28 @@ module MuffinMan::Lwa
23
23
  end
24
24
  JSON.parse(response.body)["refresh_token"]
25
25
  end
26
+
27
+ def self.get_access_token(scope, client_id, client_secret)
28
+ body = {
29
+ grant_type: "client_credentials",
30
+ scope: scope,
31
+ client_id: client_id,
32
+ client_secret: client_secret
33
+ }
34
+
35
+ response = Typhoeus.post(
36
+ ACCESS_TOKEN_URL,
37
+ body: URI.encode_www_form(body),
38
+ headers: {
39
+ "Content-Type" => "application/x-www-form-urlencoded;charset=UTF-8"
40
+ }
41
+ )
42
+ if response.code != 200
43
+ error_body = JSON.parse(response.body)
44
+ error = "#{error_body["error"]}: #{error_body["error_description"]}"
45
+ raise MuffinMan::Error, error
46
+ end
47
+ JSON.parse(response.body)["access_token"]
48
+ end
26
49
  end
27
50
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MuffinMan
4
+ module Sellers
5
+ class V1 < SpApiClient
6
+ # This is only available in the EU region.
7
+ def account
8
+ @local_var_path = "/sellers/v1/account"
9
+ @request_type = "GET"
10
+ call_api
11
+ end
12
+
13
+ def marketplace_participations
14
+ @local_var_path = "/sellers/v1/marketplaceParticipations"
15
+ @request_type = "GET"
16
+ call_api
17
+ end
18
+ end
19
+ end
20
+ end
@@ -108,7 +108,7 @@ module MuffinMan
108
108
  "Content-Type" => "application/x-www-form-urlencoded;charset=UTF-8"
109
109
  }
110
110
  )
111
- raise SpApiAuthError, response if response.failure?
111
+ raise SpApiAuthError, response unless response.success?
112
112
 
113
113
  JSON.parse(response.body)
114
114
  end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MuffinMan
4
+ module Uploads
5
+ class V20201101 < SpApiClient
6
+ # Creates a new upload destination for a resource.
7
+ #
8
+ # This method generates a signed upload destination URL for a specific resource
9
+ # that you can use to upload files to Amazon SP-API.
10
+ #
11
+ # @param [String] marketplace_id
12
+ # The identifier of the marketplace for the request (e.g., 'ATVPDKIKX0DER').
13
+ # @param [String] resource
14
+ # The resource type and path, such as:
15
+ # - `/messaging/v1/orders/{amazonOrderId}/messages/legalDisclosure`
16
+ # - `aplus/2020-11-01/contentDocuments`.
17
+ # @param [String] content_md5
18
+ # The MD5 hash of the file's content. Use `Digest::MD5.file(file_path).hexdigest` to calculate this.
19
+ # @param [String] content_type (optional)
20
+ # The content type of the file (e.g., 'application/pdf').
21
+ # @return [Hash]
22
+ # The response from the API, which includes the signed upload URL and additional metadata.
23
+ # @raise [StandardError]
24
+ # Raises an error if the API request fails.
25
+ #
26
+ # @example
27
+ # client = MuffinMan::Uploads::V20201101.new
28
+ # response = client.create_upload_destination_for_resource(
29
+ # "ATVPDKIKX0DER",
30
+ # "aplus/2020-11-01/contentDocuments",
31
+ # "510700ca1b152c729b62f2fd13c8dbbe",
32
+ # "application/pdf"
33
+ # )
34
+ # puts response
35
+ def create_upload_destination_for_resource(marketplace_id, resource, content_md5, content_type: nil)
36
+ @local_var_path = "/uploads/2020-11-01/uploadDestinations/#{resource}"
37
+ @query_params = { "marketplaceIds" => marketplace_id, "contentMD5" => content_md5 }
38
+ @query_params["contentType"] = content_type if content_type
39
+ @request_type = "POST"
40
+
41
+ call_api
42
+ end
43
+ end
44
+ end
45
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MuffinMan
4
- VERSION = "2.4.9"
4
+ VERSION = "2.4.11"
5
5
  end
data/lib/muffin_man.rb CHANGED
@@ -26,6 +26,7 @@ require "muffin_man/feeds/v20210630"
26
26
  require "muffin_man/notifications/v1"
27
27
  require "muffin_man/merchant_fulfillment/v0"
28
28
  require "muffin_man/awd/v20240509"
29
+ require "muffin_man/sellers/v1"
29
30
  require "muffin_man/vendor_direct_fulfillment_inventory/v1"
30
31
  require "muffin_man/vendor_direct_fulfillment_orders/v20211228"
31
32
  require "muffin_man/vendor_direct_fulfillment_payments/v1"
@@ -36,6 +37,9 @@ require "muffin_man/vendor_orders/v1"
36
37
  require "muffin_man/vendor_shipments/v1"
37
38
  require "muffin_man/vendor_transaction_status/v1"
38
39
  require "muffin_man/customer_feedback/v20240601"
40
+ require "muffin_man/uploads/v20201101"
41
+ require "muffin_man/aplus_content/v20201101"
42
+ require "muffin_man/application_management/v20231130"
39
43
 
40
44
  module MuffinMan
41
45
  class Error < StandardError; end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muffin_man
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.9
4
+ version: 2.4.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin
8
8
  - Jason
9
9
  - Nate
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2024-12-13 00:00:00.000000000 Z
13
+ date: 2025-01-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -130,7 +130,7 @@ dependencies:
130
130
  - - ">="
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
- description:
133
+ description:
134
134
  email:
135
135
  - gavin@pattern.com
136
136
  - jason@pattern.com
@@ -153,6 +153,8 @@ files:
153
153
  - bin/console
154
154
  - bin/setup
155
155
  - lib/muffin_man.rb
156
+ - lib/muffin_man/aplus_content/v20201101.rb
157
+ - lib/muffin_man/application_management/v20231130.rb
156
158
  - lib/muffin_man/authorization/v1.rb
157
159
  - lib/muffin_man/awd/v20240509.rb
158
160
  - lib/muffin_man/catalog_items/base_api.rb
@@ -188,9 +190,11 @@ files:
188
190
  - lib/muffin_man/request_helpers/outbound_fulfillment/item.rb
189
191
  - lib/muffin_man/request_helpers/outbound_fulfillment/v20200701.rb
190
192
  - lib/muffin_man/sandbox_helpers/merchant_fulfillment/create_shipment_body.json
193
+ - lib/muffin_man/sellers/v1.rb
191
194
  - lib/muffin_man/solicitations/v1.rb
192
195
  - lib/muffin_man/sp_api_client.rb
193
196
  - lib/muffin_man/tokens/v20210301.rb
197
+ - lib/muffin_man/uploads/v20201101.rb
194
198
  - lib/muffin_man/vendor_direct_fulfillment_inventory/v1.rb
195
199
  - lib/muffin_man/vendor_direct_fulfillment_orders/v20211228.rb
196
200
  - lib/muffin_man/vendor_direct_fulfillment_payments/v1.rb
@@ -207,7 +211,7 @@ homepage: https://github.com/patterninc/muffin_man
207
211
  licenses:
208
212
  - MIT
209
213
  metadata: {}
210
- post_install_message:
214
+ post_install_message:
211
215
  rdoc_options: []
212
216
  require_paths:
213
217
  - lib
@@ -222,8 +226,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
226
  - !ruby/object:Gem::Version
223
227
  version: '0'
224
228
  requirements: []
225
- rubygems_version: 3.0.3.1
226
- signing_key:
229
+ rubygems_version: 3.1.6
230
+ signing_key:
227
231
  specification_version: 4
228
232
  summary: Amazon Selling Partner API client
229
233
  test_files: []