Class: MuffinMan::FulfillmentInbound::V0

Inherits:
SpApiClient show all
Defined in:
lib/muffin_man/fulfillment_inbound/v0.rb

Constant Summary collapse

SANDBOX_GET_LABELS_PARAMS =
{
  "shipmentId" => "348975493",
  "PageType" => "PackageLabel_Letter_2",
  "LabelType" => "BARCODE_2D"
}.freeze
SANDBOX_SHIPMENT_ID =
"shipmentId1".freeze

Constants inherited from SpApiClient

SpApiClient::ACCESS_TOKEN_URL, SpApiClient::AWS_REGION_MAP, SpApiClient::SERVICE_NAME, SpApiClient::UNPROCESSABLE_ENTITY_STATUS_CODE

Instance Attribute Summary

Attributes inherited from SpApiClient

#access_token_cache_key, #aws_access_key_id, #aws_secret_access_key, #client_id, #client_secret, #config, #credentials, #local_var_path, #pii_data_elements, #query_params, #refresh_token, #region, #request_body, #request_type, #sandbox, #scope, #sts_iam_role_arn

Instance Method Summary collapse

Methods inherited from SpApiClient

#initialize

Constructor Details

This class inherits a constructor from MuffinMan::SpApiClient

Instance Method Details

#confirm_transport(shipment_id) ⇒ Object



127
128
129
130
131
132
# File 'lib/muffin_man/fulfillment_inbound/v0.rb', line 127

def confirm_transport(shipment_id)
  shipment_id = SANDBOX_SHIPMENT_ID if sandbox
  @local_var_path = "/fba/inbound/v0/shipments/#{shipment_id}/transport/confirm"
  @request_type = "POST"
  call_api
end

#create_inbound_shipment(shipment_id, marketplace_id, inbound_shipment_header, inbound_shipment_items) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/muffin_man/fulfillment_inbound/v0.rb', line 28

def create_inbound_shipment(shipment_id, marketplace_id, inbound_shipment_header, inbound_shipment_items)
  @local_var_path = "/fba/inbound/v0/shipments/#{shipment_id}"
  @request_body = {
    "MarketplaceId": marketplace_id,
    "InboundShipmentHeader": inbound_shipment_header,
    "InboundShipmentItems": inbound_shipment_items,
  }
  @request_type = "POST"
  call_api
end

#create_inbound_shipment_plan(ship_from_address, label_prep_preference, inbound_shipment_plan_request_items, ship_to_country_code: nil, ship_to_country_subdivision_code: nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/muffin_man/fulfillment_inbound/v0.rb', line 15

def create_inbound_shipment_plan(ship_from_address, label_prep_preference, inbound_shipment_plan_request_items, ship_to_country_code: nil, ship_to_country_subdivision_code: nil)
  @local_var_path = "/fba/inbound/v0/plans"
  @request_body = {
    "ShipFromAddress" => ship_from_address,
    "LabelPrepPreference" => label_prep_preference,
    "InboundShipmentPlanRequestItems" => inbound_shipment_plan_request_items,
  }
  @request_body["ShipToCountryCode"] = ship_to_country_code unless ship_to_country_code.nil?
  @request_body["ShipToCountrySubdivisionCode"] = ship_to_country_subdivision_code unless ship_to_country_subdivision_code.nil?
  @request_type = "POST"
  call_api
end

#estimate_transport(shipment_id) ⇒ Object



113
114
115
116
117
118
# File 'lib/muffin_man/fulfillment_inbound/v0.rb', line 113

def estimate_transport(shipment_id)
  shipment_id = SANDBOX_SHIPMENT_ID if sandbox
  @local_var_path = "/fba/inbound/v0/shipments/#{shipment_id}/transport/estimate"
  @request_type = "POST"
  call_api
end

#get_labels(shipment_id, page_type, label_type, number_of_packages: nil, package_labels_to_print: [], number_of_pallets: nil, page_size: nil, page_start_index: nil) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/muffin_man/fulfillment_inbound/v0.rb', line 71

def get_labels(shipment_id, page_type, label_type, number_of_packages: nil, package_labels_to_print: [], number_of_pallets: nil, page_size: nil, page_start_index: nil)
  @query_params = {
    "shipmentID" => shipment_id,
    "PageType" => page_type,
    "LabelType" => label_type
  }
  if sandbox
    shipment_id = SANDBOX_GET_LABELS_PARAMS["shipmentId"]
    @query_params = SANDBOX_GET_LABELS_PARAMS.except("shipmentId")
  else
    @query_params["NumberOfPackages"] = number_of_packages unless number_of_packages.nil?
    @query_params["PackageLabelsToPrint"] = package_labels_to_print.join(",") if package_labels_to_print.any?
    @query_params["NumberOfPallets"] = number_of_pallets unless number_of_pallets.nil?
    @query_params["PageSize"] = page_size unless page_size.nil?
    @query_params["PageStartIndex"] = page_start_index unless page_start_index.nil?
  end
  @local_var_path = "/fba/inbound/v0/shipments/#{shipment_id}/labels"
  @request_type = "GET"
  call_api
end

#get_prep_instructions(ship_to_country_code, seller_sku_list: [], asin_list: []) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/muffin_man/fulfillment_inbound/v0.rb', line 4

def get_prep_instructions(ship_to_country_code, seller_sku_list: [], asin_list: [])
  @local_var_path = "/fba/inbound/v0/prepInstructions"
  @query_params = {
    "ShipToCountryCode" => ship_to_country_code
  }
  @query_params["SellerSKUList"] = seller_sku_list.join(",") if seller_sku_list.any?
  @query_params["ASINList"] = asin_list.join(",") if asin_list.any?
  @request_type = "GET"
  call_api
end

#get_shipment_items_by_shipment_id(shipment_id, marketplace_id) ⇒ Object



92
93
94
95
96
97
98
99
# File 'lib/muffin_man/fulfillment_inbound/v0.rb', line 92

def get_shipment_items_by_shipment_id(shipment_id, marketplace_id)
  @local_var_path = "/fba/inbound/v0/shipments/#{shipment_id}/items"
  @query_params = {
    "MarketplaceId" => marketplace_id,
  }
  @request_type = "GET"
  call_api
end

#get_shipments(query_type, marketplace_id, shipment_status_list: [], shipment_id_list: [], last_updated_after: nil, last_updated_before: nil, next_token: nil) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/muffin_man/fulfillment_inbound/v0.rb', line 39

def get_shipments(query_type, marketplace_id, shipment_status_list: [], shipment_id_list: [], last_updated_after: nil, last_updated_before: nil, next_token: nil)
  @local_var_path = "/fba/inbound/v0/shipments"
  @query_params = {
    "MarketplaceId" => marketplace_id,
    "QueryType" => query_type,
  }
  @query_params["ShipmentStatusList"] = shipment_status_list.join(",") if shipment_status_list.any?
  @query_params["ShipmentIdList"] = shipment_id_list.join(",") if shipment_id_list.any?
  @query_params["LastUpdatedAfter"] = last_updated_after unless last_updated_after.nil?
  @query_params["LastUpdatedBefore"] = last_updated_before unless last_updated_before.nil?
  @query_params["NextToken"] = next_token unless next_token.nil?

  @request_type = "GET"
  call_api
end

#get_transport_details(shipment_id) ⇒ Object



120
121
122
123
124
125
# File 'lib/muffin_man/fulfillment_inbound/v0.rb', line 120

def get_transport_details(shipment_id)
  shipment_id = SANDBOX_SHIPMENT_ID if sandbox
  @local_var_path = "/fba/inbound/v0/shipments/#{shipment_id}/transport"
  @request_type = "GET"
  call_api
end

#put_transport_details(shipment_id, is_partnered, shipment_type, transport_details) ⇒ Object



101
102
103
104
105
106
107
108
109
110
# File 'lib/muffin_man/fulfillment_inbound/v0.rb', line 101

def put_transport_details(shipment_id, is_partnered, shipment_type, transport_details)
  @local_var_path = "/fba/inbound/v0/shipments/#{shipment_id}/transport"
  @request_body = {
    "IsPartnered": is_partnered,
    "ShipmentType": shipment_type,
    "TransportDetails": transport_details,
  }
  @request_type = "PUT"
  call_api
end

#update_inbound_shipment(shipment_id, marketplace_id, inbound_shipment_header, inbound_shipment_items) ⇒ Object



55
56
57
58
59
60
61
62
63
64
# File 'lib/muffin_man/fulfillment_inbound/v0.rb', line 55

def update_inbound_shipment(shipment_id, marketplace_id, inbound_shipment_header, inbound_shipment_items)
  @local_var_path = "/fba/inbound/v0/shipments/#{shipment_id}"
  @request_body = {
    "MarketplaceId": marketplace_id,
    "InboundShipmentHeader": inbound_shipment_header,
    "InboundShipmentItems": inbound_shipment_items,
  }
  @request_type = "PUT"
  call_api
end

#void_transport(shipment_id) ⇒ Object



134
135
136
137
138
139
# File 'lib/muffin_man/fulfillment_inbound/v0.rb', line 134

def void_transport(shipment_id)
  shipment_id = SANDBOX_SHIPMENT_ID if sandbox
  @local_var_path = "/fba/inbound/v0/shipments/#{shipment_id}/transport/void"
  @request_type = "POST"
  call_api
end