Skip to content

Commit

Permalink
Add fulfillment_policy.get method call
Browse files Browse the repository at this point in the history
  • Loading branch information
nepalez committed Aug 9, 2018
1 parent 994da34 commit 606bbae
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -9,4 +9,3 @@
/tmp/
*.gem
.rspec_status
*.yml
1 change: 1 addition & 0 deletions lib/ebay_api/operations/sell/account/fulfillment_policy.rb
Expand Up @@ -9,3 +9,4 @@ class EbayAPI
end

require_relative "fulfillment_policy/delete"
require_relative "fulfillment_policy/get"
15 changes: 15 additions & 0 deletions lib/ebay_api/operations/sell/account/fulfillment_policy/get.rb
@@ -0,0 +1,15 @@
class EbayAPI
scope :sell do
scope :account do
scope :fulfillment_policy do
# @see https://developer.ebay.com/api-docs/sell/account/resources/fulfillment_policy/methods/getFulfillmentPolicy
operation :get do
option :id, proc(&:to_s)

path { id }
http_method :get
end
end
end
end
end
6 changes: 6 additions & 0 deletions spec/fixtures/sell/account/fulfillment_policy/get/success
@@ -0,0 +1,6 @@
HTTP/1.1 200 OK
Content-Length: 724
Content-Type: application/json

{"name":"Domestic free shipping","marketplaceId":"EBAY_US","categoryTypes":[{"name":"ALL_EXCLUDING_MOTORS_VEHICLES","default":false}],"handlingTime":{"value":1,"unit":"DAY"},"shippingOptions":[{"optionType":"DOMESTIC","costType":"FLAT_RATE","shippingServices":[{"sortOrder":1,"shippingCarrierCode":"USPS","shippingServiceCode":"USPSPriorityFlatRateBox","shippingCost":{"value":0.0,"currency":"USD"},"additionalShippingCost":{"value":0.0,"currency":"USD"},"freeShipping":true,"buyerResponsibleForShipping":false,"buyerResponsibleForPickup":false}],"insuranceOffered":false,"insuranceFee":{"value":0.0,"currency":"USD"}}],"globalShipping":false,"pickupDropOff":false,"freightShipping":false,"fulfillmentPolicyId":"5733588000"}

33 changes: 33 additions & 0 deletions spec/fixtures/sell/account/fulfillment_policy/get/success.yml
@@ -0,0 +1,33 @@
---
name: "Domestic free shipping"
marketplaceId: "EBAY_US"
categoryTypes:
- name: "ALL_EXCLUDING_MOTORS_VEHICLES"
default: false
handlingTime:
value: 1
unit: "DAY"
shippingOptions:
- optionType: "DOMESTIC"
costType: "FLAT_RATE"
shippingServices:
- sortOrder: 1
shippingCarrierCode: "USPS"
shippingServiceCode: "USPSPriorityFlatRateBox"
shippingCost:
value: 0.0
currency: "USD"
additionalShippingCost:
value: 0.0
currency: "USD"
freeShipping: true
buyerResponsibleForShipping: false
buyerResponsibleForPickup: false
insuranceOffered: false
insuranceFee:
value: 0.0
currency: "USD"
globalShipping: false
pickupDropOff: false
freightShipping: false
fulfillmentPolicyId: "5733588000"
31 changes: 31 additions & 0 deletions spec/operations/sell/account/fulfillment_policy/get_spec.rb
@@ -0,0 +1,31 @@
RSpec.describe EbayAPI, ".sell.account.fulfillment_policy.get" do
let(:client) { described_class.new(settings) }
let(:scope) { client.sell.account(version: version).fulfillment_policy }
let(:settings) { yaml_fixture_file("settings.valid.yml") }
let(:version) { "1.2.0" }
let(:url) do
"https://api.ebay.com/sell/account/v1/fulfillment_policy/5733588000"
end

before { stub_request(:get, url).to_return(response) }
subject { scope.get id: "5733588000" }

context "success" do
let(:response) do
open_fixture_file "sell/account/fulfillment_policy/get/success"
end

let(:policy) do
yaml_fixture_file "sell/account/fulfillment_policy/get/success.yml"
end

it "sends a request" do
subject
expect(a_request(:get, url)).to have_been_made
end

it "returns the policy" do
expect(subject).to eq policy
end
end
end

0 comments on commit 606bbae

Please sign in to comment.