muffin_man 2.1.0 → 2.1.2
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 +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +14 -0
- data/lib/muffin_man/catalog_items/base_api.rb +6 -0
- data/lib/muffin_man/enable_logger.rb +18 -0
- data/lib/muffin_man/finances/v0.rb +4 -0
- data/lib/muffin_man/listings/v20210801.rb +18 -0
- data/lib/muffin_man/reports/v20210630.rb +1 -0
- data/lib/muffin_man/sp_api_client.rb +8 -2
- data/lib/muffin_man/version.rb +1 -1
- data/lib/muffin_man.rb +6 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e76d913a68a8015a4b14b3f91083ffb0995f18f4fcb2a32561ab6ebb54606a06
|
4
|
+
data.tar.gz: 8c020662237e128bab18104b1e3283cc9f93f21336c952acc4a19b5741088196
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29d252e4e79d7e2c548468b5b941673831ca1ff946b4d14cd9dc8ccabece39d148f76a6578aba8b4d0c3251dd83732c1cb24cf139ff76f61e8107bedd9d1cac6
|
7
|
+
data.tar.gz: 131ccf94eda1c1131a6f72ff937f5a2f3437278a8b60a445dca95fec48b787dd72a2110fb10a3f606b5cb386a5b0cde4e84162caf680b0b69bbac203f3f48946
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# 2.1.2 [#63](https://github.com/patterninc/muffin_man/pull/63)
|
2
|
+
|
3
|
+
- Support for patchListingsItem
|
4
|
+
|
5
|
+
# 2.1.1 [#62](https://github.com/patterninc/muffin_man/pull/62)
|
6
|
+
|
7
|
+
- SearchCatalogItems validations on keywords & identifiers
|
8
|
+
|
1
9
|
# 2.1.0 [#58](https://github.com/patterninc/muffin_man/pull/58)
|
2
10
|
|
3
11
|
- 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).
|
@@ -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
|
@@ -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[:
|
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
|
|
data/lib/muffin_man/version.rb
CHANGED
data/lib/muffin_man.rb
CHANGED
@@ -35,15 +35,19 @@ module MuffinMan
|
|
35
35
|
end
|
36
36
|
|
37
37
|
class << self
|
38
|
-
attr_accessor :configuration
|
38
|
+
attr_accessor :configuration, :logger
|
39
39
|
end
|
40
40
|
|
41
41
|
def self.configure
|
42
42
|
self.configuration ||= Configuration.new
|
43
43
|
yield(configuration)
|
44
|
+
self.logger = configuration.logger if configuration.logger
|
44
45
|
end
|
45
46
|
|
46
47
|
class Configuration
|
47
|
-
attr_accessor :save_access_token, :get_access_token
|
48
|
+
attr_accessor :save_access_token, :get_access_token, :logger
|
48
49
|
end
|
49
50
|
end
|
51
|
+
|
52
|
+
# Set default logger
|
53
|
+
MuffinMan.logger = Logger.new($stdout)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muffin_man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2024-05-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -157,6 +157,7 @@ files:
|
|
157
157
|
- lib/muffin_man/catalog_items/base_api.rb
|
158
158
|
- lib/muffin_man/catalog_items/v20201201.rb
|
159
159
|
- lib/muffin_man/catalog_items/v20220401.rb
|
160
|
+
- lib/muffin_man/enable_logger.rb
|
160
161
|
- lib/muffin_man/fba_inventory/v1.rb
|
161
162
|
- lib/muffin_man/feeds/v20210630.rb
|
162
163
|
- lib/muffin_man/finances/v0.rb
|