muffin_man 2.1.0 → 2.1.3

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: 42d41a72e708c859b3fba7fd92fdcae714730a8bb959d543cc74c1c44bbaa7a8
4
- data.tar.gz: 66c384cee7964c5041528132e822feda6e4bc32324bfa441499f4e031e1abf5c
3
+ metadata.gz: 6e9269248aa6303968c89ad3f90d7a6165b249cebaa15b905ee0596b2a8916ce
4
+ data.tar.gz: 61dcfad92370fd8553a702976dffd4109b9e5eaf9158929c45803ca23b0af238
5
5
  SHA512:
6
- metadata.gz: 2dcafda67c6adb2230feb4e71dc5120f5d26ed268b4165aa5e0cbf72782bdfb1d0a48950679b7bd6756ee2c784f0111cecc0b077eeac21ffd7911b2dfb9c4eb6
7
- data.tar.gz: 4df599f9720c61ceba199a64f2a8f63dd3fb9d80a7722686bb719ea31d30612f65292eb5b25b62a005fc4afec2ca49415bf68df72b91ed2793bb5c41a3e55b42
6
+ metadata.gz: cb1133daaa98b531f1123985494fe1718de374e00877109a21579592758fc10f7aef91f0f76612dec83bf39357ea6ef449ca7063ef49f8515561c4598f421db6
7
+ data.tar.gz: b4dc27b5e26ffd6cf3d91f386225431e22006bc96217411300c2122ec8a6a3b50397399ed3c5c4bf0a29c408453943b782dc17ba8fcb938ddacdc1956cbfc962
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # 2.1.3
2
+
3
+ - Support for AWD getInboundShipment [#64](https://github.com/patterninc/muffin_man/pull/64)
4
+
5
+ # 2.1.2 [#63](https://github.com/patterninc/muffin_man/pull/63)
6
+
7
+ - Support for patchListingsItem
8
+
9
+ # 2.1.1 [#62](https://github.com/patterninc/muffin_man/pull/62)
10
+
11
+ - SearchCatalogItems validations on keywords & identifiers
12
+
1
13
  # 2.1.0 [#58](https://github.com/patterninc/muffin_man/pull/58)
2
14
 
3
15
  - Support for Product Type Definitions
data/README.md CHANGED
@@ -56,6 +56,16 @@ JSON.parse(response.body)
56
56
 
57
57
  You can optionally use Amazon's sandbox environment by specifying `client = MuffinMan::Solicitations.new(credentials, sandbox = true)`
58
58
 
59
+ ### Set Custom Logger
60
+
61
+ By default MuffinMan will log to standard out. To customize the logger used:
62
+
63
+ ```ruby
64
+ MuffinMan.configure do |config|
65
+ config.logger = Logger.new('log/sp-api.log')
66
+ end
67
+ ```
68
+
59
69
  ### Access Token Caching
60
70
 
61
71
  You can save and retrieve the LWA refresh token by defining a lambda in your initializers.
@@ -94,6 +104,10 @@ auth_code = resp['payload']['authorizationCode']
94
104
  refresh_token = MuffinMan::Lwa::AuthHelper.get_refresh_token(CLIENT_ID, CLIENT_SECRET, auth_code)
95
105
  ```
96
106
 
107
+ ### Debugging
108
+
109
+ To use Typheous' verbose mode set env variable `MUFFIN_MAN_DEBUG=true`
110
+
97
111
  ## Contributing
98
112
 
99
113
  Bug reports and pull requests are welcome on GitHub at https://github.com/patterninc/muffin_man. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/patterninc/muffin_man/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MuffinMan
4
+ module Awd
5
+ class V20240509 < SpApiClient
6
+ AWD_PATH = "/awd/2024-05-09"
7
+
8
+ def get_inbound_shipment(shipment_id)
9
+ @local_var_path = "#{AWD_PATH}/inboundShipments/#{shipment_id}"
10
+ @request_type = "GET"
11
+ call_api
12
+ end
13
+ end
14
+ end
15
+ end
@@ -30,6 +30,7 @@ module MuffinMan
30
30
  end
31
31
  @keywords = keywords.is_a?(Array) ? keywords : [keywords]
32
32
  @identifiers = params["identifiers"].is_a?(Array) ? params["identifiers"] : [params["identifiers"]]
33
+ validate_keywords_and_identifiers
33
34
  @marketplace_ids = marketplace_ids.is_a?(Array) ? marketplace_ids : [marketplace_ids]
34
35
  @params = params
35
36
  @local_var_path = "/catalog/#{api_version}/items"
@@ -68,6 +69,11 @@ module MuffinMan
68
69
  def search_catalog_items_params
69
70
  BASE_SEARCH_CATALOG_ITEMS_PARAMS + self.class::SEARCH_CATALOG_ITEMS_PARAMS
70
71
  end
72
+
73
+ def validate_keywords_and_identifiers
74
+ raise MuffinMan::Error, "Keywords cannot be used with Identifiers" if @keywords.any? && @identifiers.any?
75
+ raise MuffinMan::Error, "Keywords or Identifiers must be present" if @keywords.none? && @identifiers.none?
76
+ end
71
77
  end
72
78
  end
73
79
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MuffinMan
4
+ module EnableLogger
5
+ LOGGING_ENABLED = true
6
+
7
+ def log_request_and_response(level, res)
8
+ log_info = "REQUEST\n
9
+ canonical_uri:#{canonical_uri}\n\n
10
+ query_params:#{query_params}\n\n
11
+ RESPONSE\n
12
+ response_headers=#{res.headers}\n\n
13
+ response_body=#{res.body}\n\n
14
+ "
15
+ MuffinMan.logger.send(level, log_info)
16
+ end
17
+ end
18
+ end
@@ -1,6 +1,10 @@
1
+ require "muffin_man/enable_logger"
2
+
1
3
  module MuffinMan
2
4
  module Finances
3
5
  class V0 < SpApiClient
6
+ include EnableLogger
7
+
4
8
  def list_financial_event_groups(max_results_per_page = nil, financial_event_group_started_before = nil, financial_event_group_started_after = nil, next_token = nil)
5
9
  @local_var_path = "/finances/v0/financialEventGroups"
6
10
  @query_params = {}
@@ -47,6 +47,24 @@ module MuffinMan
47
47
  @request_type = "DELETE"
48
48
  call_api
49
49
  end
50
+
51
+ def patch_listings_item(seller_id, sku, marketplace_ids, product_type, patches, included_data: [], mode: nil,
52
+ issue_locale: nil)
53
+ @local_var_path = "/listings/2021-08-01/items/#{seller_id}/#{sku}"
54
+ @marketplace_ids = marketplace_ids.is_a?(Array) ? marketplace_ids : [marketplace_ids]
55
+ @query_params = {
56
+ "marketplaceIds" => @marketplace_ids.join(",")
57
+ }
58
+ @query_params["includedData"] = included_data.join(",") if included_data.any?
59
+ @query_params["mode"] = mode if mode
60
+ @query_params["issueLocale"] = issue_locale if issue_locale
61
+ @request_body = {
62
+ "productType" => product_type,
63
+ "patches" => patches
64
+ }
65
+ @request_type = "PATCH"
66
+ call_api
67
+ end
50
68
  end
51
69
  end
52
70
  end
@@ -57,6 +57,7 @@ module MuffinMan
57
57
  report_id = sandbox ? SANDBOX_REPORT_ID : report_id
58
58
  @local_var_path = "/reports/2021-06-30/reports/#{report_id}"
59
59
  @request_type = "GET"
60
+ @request_body = nil
60
61
  call_api
61
62
  end
62
63
 
@@ -42,14 +42,20 @@ module MuffinMan
42
42
  private
43
43
 
44
44
  def call_api
45
- Typhoeus.send(request_type.downcase.to_sym, request.url, request_opts)
45
+ res = Typhoeus.send(request_type.downcase.to_sym, request.url, request_opts)
46
+ if self.class.const_defined?("LOGGING_ENABLED")
47
+ level = res.code.to_s.match?(/2\d{2}/) ? :info : :error
48
+ log_request_and_response(level, res)
49
+ end
50
+ res
46
51
  rescue SpApiAuthError => e
47
52
  e.auth_response
48
53
  end
49
54
 
50
55
  def request_opts
51
56
  opts = { headers: headers }
52
- opts[:body] = request_body.to_json if request_body
57
+ opts[:verbose] = true if ENV.fetch("MUFFIN_MAN_DEBUG", nil) == "true"
58
+ opts[:body] = request_body.to_json if request_body && request_type != "GET" && request_type != "HEAD"
53
59
  opts
54
60
  end
55
61
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MuffinMan
4
- VERSION = "2.1.0"
4
+ VERSION = "2.1.3"
5
5
  end
data/lib/muffin_man.rb CHANGED
@@ -21,6 +21,7 @@ require "muffin_man/request_helpers"
21
21
  require "muffin_man/feeds/v20210630"
22
22
  require "muffin_man/notifications/v1"
23
23
  require "muffin_man/merchant_fulfillment/v0"
24
+ require "muffin_man/awd/v20240509"
24
25
 
25
26
  module MuffinMan
26
27
  class Error < StandardError; end
@@ -35,15 +36,19 @@ module MuffinMan
35
36
  end
36
37
 
37
38
  class << self
38
- attr_accessor :configuration
39
+ attr_accessor :configuration, :logger
39
40
  end
40
41
 
41
42
  def self.configure
42
43
  self.configuration ||= Configuration.new
43
44
  yield(configuration)
45
+ self.logger = configuration.logger if configuration.logger
44
46
  end
45
47
 
46
48
  class Configuration
47
- attr_accessor :save_access_token, :get_access_token
49
+ attr_accessor :save_access_token, :get_access_token, :logger
48
50
  end
49
51
  end
52
+
53
+ # Set default logger
54
+ MuffinMan.logger = Logger.new($stdout)
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.1.0
4
+ version: 2.1.3
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: 2023-09-26 00:00:00.000000000 Z
13
+ date: 2024-07-09 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
@@ -154,9 +154,11 @@ files:
154
154
  - bin/setup
155
155
  - lib/muffin_man.rb
156
156
  - lib/muffin_man/authorization/v1.rb
157
+ - lib/muffin_man/awd/v20240509.rb
157
158
  - lib/muffin_man/catalog_items/base_api.rb
158
159
  - lib/muffin_man/catalog_items/v20201201.rb
159
160
  - lib/muffin_man/catalog_items/v20220401.rb
161
+ - lib/muffin_man/enable_logger.rb
160
162
  - lib/muffin_man/fba_inventory/v1.rb
161
163
  - lib/muffin_man/feeds/v20210630.rb
162
164
  - lib/muffin_man/finances/v0.rb
@@ -191,7 +193,7 @@ homepage: https://github.com/patterninc/muffin_man
191
193
  licenses:
192
194
  - MIT
193
195
  metadata: {}
194
- post_install_message:
196
+ post_install_message:
195
197
  rdoc_options: []
196
198
  require_paths:
197
199
  - lib
@@ -206,8 +208,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
206
208
  - !ruby/object:Gem::Version
207
209
  version: '0'
208
210
  requirements: []
209
- rubygems_version: 3.0.3
210
- signing_key:
211
+ rubygems_version: 3.4.19
212
+ signing_key:
211
213
  specification_version: 4
212
214
  summary: Amazon Selling Partner API client
213
215
  test_files: []