Skip to content

Commit

Permalink
Improve yardoc
Browse files Browse the repository at this point in the history
  • Loading branch information
hakanensari committed Oct 7, 2024
1 parent 5748ac3 commit 1bcc290
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 25 deletions.
23 changes: 11 additions & 12 deletions lib/peddler/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down Expand Up @@ -132,17 +124,24 @@ def meter(rate_limit)
end
end

# @param [#call]
attr_writer :parser

# @!attribute [r]
# @!attribute parser
# @return [#call]
def parser
@parser || self.class.parser
end

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
Expand Down
2 changes: 1 addition & 1 deletion lib/peddler/response_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 0 additions & 12 deletions test/peddler/api_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1bcc290

Please sign in to comment.