Class: MuffinMan::MerchantFulfillment::V0

Inherits:
SpApiClient
  • Object
show all
Defined in:
lib/muffin_man/merchant_fulfillment/v0.rb

Constant Summary collapse

CANCEL_SANDBOX_SHIPMENT_ID =
"be7a0a53-00c3-4f6f-a63a-639f76ee9253"

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

#cancel_shipment(shipment_id) ⇒ Object



23
24
25
26
27
28
# File 'lib/muffin_man/merchant_fulfillment/v0.rb', line 23

def cancel_shipment(shipment_id)
  shipment_id = CANCEL_SANDBOX_SHIPMENT_ID if sandbox
  @local_var_path = "/mfn/v0/shipments/#{shipment_id}"
  @request_type = "DELETE"
  call_api
end

#create_shipment(shipment_request_details, shipping_service_id, shipping_service_offering_id: nil, hazmat_type: nil, label_format_option: {}, shipment_level_seller_inputs_list: []) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/muffin_man/merchant_fulfillment/v0.rb', line 30

def create_shipment(shipment_request_details, shipping_service_id,
                    shipping_service_offering_id: nil, hazmat_type: nil, label_format_option: {},
                    shipment_level_seller_inputs_list: [])
  @local_var_path = "/mfn/v0/shipments"
  @request_body = {
    "ShipmentRequestDetails" => shipment_request_details,
    "ShippingServiceId" => shipping_service_id
  }
  @request_body["ShippingServiceOfferId"] = shipping_service_offering_id unless shipping_service_offering_id.nil?
  @request_body["HazmatType"] = hazmat_type unless hazmat_type.nil?
  @request_body["LabelFormatOption"] = label_format_option unless label_format_option.empty?
  if shipment_level_seller_inputs_list.any?
    @request_body["ShipmentLevelSellerInputsList"] = shipment_level_seller_inputs_list
  end
  if sandbox
    @request_body = JSON.parse(
      File.read(
        File.expand_path(
          "../sandbox_helpers/merchant_fulfillment/create_shipment_body.json",
          File.dirname(__FILE__)
        )
      )
    )
  end
  @request_type = "POST"
  call_api
end

#get_additional_seller_inputs(shipping_service_id, ship_from_address, order_id) ⇒ Object



58
59
60
61
62
63
64
65
66
67
# File 'lib/muffin_man/merchant_fulfillment/v0.rb', line 58

def get_additional_seller_inputs(shipping_service_id, ship_from_address, order_id)
  @local_var_path = "/mfn/v0/additionalSellerInputs"
  @request_body = {
    "ShippingServiceId" => shipping_service_id,
    "ShipFromAddress" => ship_from_address,
    "OrderId" => order_id
  }
  @request_type = "POST"
  call_api
end

#get_eligible_shipment_services(shipment_request_details, shipping_offering_filter = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/muffin_man/merchant_fulfillment/v0.rb', line 6

def get_eligible_shipment_services(shipment_request_details, shipping_offering_filter = {})
  @local_var_path = "/mfn/v0/eligibleShippingServices"
  @request_body = {
    "ShipmentRequestDetails" => shipment_request_details
  }
  @request_body["ShippingOfferingFilter"] = shipping_offering_filter unless shipping_offering_filter.empty?
  @request_type = "POST"
  call_api
end

#get_shipment(shipment_id) ⇒ Object



16
17
18
19
20
# File 'lib/muffin_man/merchant_fulfillment/v0.rb', line 16

def get_shipment(shipment_id)
  @local_var_path = "/mfn/v0/shipments/#{shipment_id}"
  @request_type = "GET"
  call_api
end