diff --git a/lib/peddler/api.rb b/lib/peddler/api.rb index 8c4b5644..f10c1f92 100644 --- a/lib/peddler/api.rb +++ b/lib/peddler/api.rb @@ -38,6 +38,8 @@ def endpoint_uri sandbox? ? endpoint.sandbox : endpoint.production end + # Switches to the SP-API sandbox to make test calls + # # @see https://developer-docs.amazon.com/sp-api/docs/the-selling-partner-api-sandbox # @return [self] def sandbox @@ -50,16 +52,6 @@ def sandbox? @sandbox end - # @raise [CannotSandbox] if in a sandbox environment - def cannot_sandbox! - raise CannotSandbox, "cannot run in a sandbox" if sandbox? - end - - # @raise [MustSandbox] unless in a sandbox environment - def must_sandbox! - raise MustSandbox, "must run in a sandbox" unless sandbox? - end - # @see https://developer-docs.amazon.com/sp-api/docs/include-a-user-agent-header-in-all-requests # @see https://developer-docs.amazon.com/amazon-shipping/docs/connecting-to-the-selling-partner-api#step-3-add-headers-to-the-uri # @return [HTTP::Client] @@ -132,10 +124,9 @@ def meter(rate_limit) end end - # @param [#call] attr_writer :parser - # @!attribute [r] + # @!attribute parser # @return [#call] def parser @parser || self.class.parser @@ -143,6 +134,14 @@ def parser private + def cannot_sandbox! + raise CannotSandbox, "cannot run in a sandbox" if sandbox? + end + + def must_sandbox! + raise MustSandbox, "must run in a sandbox" unless sandbox? + end + def user_agent "Peddler/#{Peddler::VERSION} (Language=Ruby; #{Socket.gethostname})" end diff --git a/lib/peddler/response_decorator.rb b/lib/peddler/response_decorator.rb index 59d8849f..d34cd22b 100644 --- a/lib/peddler/response_decorator.rb +++ b/lib/peddler/response_decorator.rb @@ -9,7 +9,7 @@ class ResponseDecorator < SimpleDelegator extend Forwardable # @!method dig(*key) - # Delegates to the Hash returned by {Response#to_h} to extract a nested + # Delegates to the Hash returned by {ResponseDecorator#to_h} to extract a nested # value specified by the sequence of keys # # @param [String] key one or more keys diff --git a/test/peddler/api_test.rb b/test/peddler/api_test.rb index 26b3960b..8f913b08 100644 --- a/test/peddler/api_test.rb +++ b/test/peddler/api_test.rb @@ -20,18 +20,6 @@ def test_sandbox assert_includes(@api.sandbox.endpoint_uri.host, "sandbox") end - def test_cannot_sandbox - assert_raises(API::CannotSandbox) do - @api.sandbox.cannot_sandbox! - end - end - - def test_must_sandbox - assert_raises(API::MustSandbox) do - @api.must_sandbox! - end - end - def test_host_header assert(@api.http.default_options.headers["Host"]) end