sp_api_clients 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +161 -0
  3. data/LICENSE +21 -0
  4. data/README.md +284 -0
  5. data/lib/amazon_sp_clients/adapter_loader.rb +28 -0
  6. data/lib/amazon_sp_clients/api_client.rb +309 -0
  7. data/lib/amazon_sp_clients/api_error.rb +37 -0
  8. data/lib/amazon_sp_clients/api_response.rb +54 -0
  9. data/lib/amazon_sp_clients/configuration.rb +144 -0
  10. data/lib/amazon_sp_clients/marketplaces.rb +63 -0
  11. data/lib/amazon_sp_clients/middlewares/raise_error.rb +166 -0
  12. data/lib/amazon_sp_clients/session.rb +124 -0
  13. data/lib/amazon_sp_clients/sp_fba_inventory.rb +8 -0
  14. data/lib/amazon_sp_clients/sp_feeds_2021.rb +8 -0
  15. data/lib/amazon_sp_clients/sp_fulfillment_outbound_2020.rb +8 -0
  16. data/lib/amazon_sp_clients/sp_listings_items_2021.rb +8 -0
  17. data/lib/amazon_sp_clients/sp_orders_v0.rb +8 -0
  18. data/lib/amazon_sp_clients/sp_reports_2021.rb +8 -0
  19. data/lib/amazon_sp_clients/sp_tokens_2021.rb +8 -0
  20. data/lib/amazon_sp_clients/sp_vdf_inventory_v1.rb +8 -0
  21. data/lib/amazon_sp_clients/sp_vdf_orders_v1.rb +8 -0
  22. data/lib/amazon_sp_clients/sp_vdf_shipping_v1.rb +8 -0
  23. data/lib/amazon_sp_clients/sp_vendor_invoices.rb +8 -0
  24. data/lib/amazon_sp_clients/sp_vendor_orders.rb +8 -0
  25. data/lib/amazon_sp_clients/sp_vendor_transaction_status.rb +8 -0
  26. data/lib/amazon_sp_clients/sp_vendors_shipments.rb +8 -0
  27. data/lib/amazon_sp_clients/token_exchange_auth.rb +82 -0
  28. data/lib/amazon_sp_clients/uploader.rb +77 -0
  29. data/lib/amazon_sp_clients/v2/api.rb +43 -0
  30. data/lib/amazon_sp_clients/v2/apis/fba_inventory.rb +80 -0
  31. data/lib/amazon_sp_clients/v2/apis/feeds_2021.rb +86 -0
  32. data/lib/amazon_sp_clients/v2/apis/fulfillment_outbound_2020.rb +184 -0
  33. data/lib/amazon_sp_clients/v2/apis/listings_items_2021.rb +144 -0
  34. data/lib/amazon_sp_clients/v2/apis/orders_v0.rb +165 -0
  35. data/lib/amazon_sp_clients/v2/apis/reports_2021.rb +117 -0
  36. data/lib/amazon_sp_clients/v2/apis/tokens_2021.rb +25 -0
  37. data/lib/amazon_sp_clients/v2/apis/vdf_inventory_v1.rb +26 -0
  38. data/lib/amazon_sp_clients/v2/apis/vdf_orders_v1.rb +61 -0
  39. data/lib/amazon_sp_clients/v2/apis/vdf_shipping_v1.rb +139 -0
  40. data/lib/amazon_sp_clients/v2/apis/vendor_invoices.rb +25 -0
  41. data/lib/amazon_sp_clients/v2/apis/vendor_orders.rb +106 -0
  42. data/lib/amazon_sp_clients/v2/apis/vendor_transaction_status.rb +25 -0
  43. data/lib/amazon_sp_clients/v2/apis/vendors_shipments.rb +120 -0
  44. data/lib/amazon_sp_clients/v2/apis.rb +82 -0
  45. data/lib/amazon_sp_clients/v2/client.rb +198 -0
  46. data/lib/amazon_sp_clients/v2/config.rb +85 -0
  47. data/lib/amazon_sp_clients/v2/credentials.rb +91 -0
  48. data/lib/amazon_sp_clients/v2/documents.rb +115 -0
  49. data/lib/amazon_sp_clients/v2/error_mapper.rb +235 -0
  50. data/lib/amazon_sp_clients/v2/errors.rb +117 -0
  51. data/lib/amazon_sp_clients/v2/lwa.rb +100 -0
  52. data/lib/amazon_sp_clients/v2/rdt.rb +104 -0
  53. data/lib/amazon_sp_clients/v2/token.rb +39 -0
  54. data/lib/amazon_sp_clients/v2.rb +33 -0
  55. data/lib/amazon_sp_clients/version.rb +3 -0
  56. data/lib/amazon_sp_clients.rb +69 -0
  57. data/lib/sp_api_clients.rb +6 -0
  58. data/sp_api_clients.gemspec +53 -0
  59. data/vendor/fba_inventory/lib/sp_fba_inventory/api/fba_inventory_api.rb +289 -0
  60. data/vendor/fba_inventory/lib/sp_fba_inventory.rb +12 -0
  61. data/vendor/feeds_2021/lib/sp_feeds_2021/api/feeds_api.rb +367 -0
  62. data/vendor/feeds_2021/lib/sp_feeds_2021.rb +12 -0
  63. data/vendor/fulfillment_outbound_2020/lib/sp_fulfillment_outbound_2020/api/fba_outbound_api.rb +845 -0
  64. data/vendor/fulfillment_outbound_2020/lib/sp_fulfillment_outbound_2020.rb +12 -0
  65. data/vendor/listings_items_2021/lib/sp_listings_items_2021/api/listings_api.rb +480 -0
  66. data/vendor/listings_items_2021/lib/sp_listings_items_2021.rb +12 -0
  67. data/vendor/orders_v0/lib/sp_orders_v0/api/orders_v0_api.rb +593 -0
  68. data/vendor/orders_v0/lib/sp_orders_v0/api/shipment_api.rb +83 -0
  69. data/vendor/orders_v0/lib/sp_orders_v0.rb +13 -0
  70. data/vendor/reports_2021/lib/sp_reports_2021/api/reports_api.rb +530 -0
  71. data/vendor/reports_2021/lib/sp_reports_2021.rb +12 -0
  72. data/vendor/tokens_2021/lib/sp_tokens_2021/api/tokens_api.rb +77 -0
  73. data/vendor/tokens_2021/lib/sp_tokens_2021.rb +12 -0
  74. data/vendor/vdf_inventory_v1/lib/sp_vdf_inventory_v1/api/update_inventory_api.rb +83 -0
  75. data/vendor/vdf_inventory_v1/lib/sp_vdf_inventory_v1.rb +12 -0
  76. data/vendor/vdf_orders_v1/lib/sp_vdf_orders_v1/api/vendor_orders_api.rb +217 -0
  77. data/vendor/vdf_orders_v1/lib/sp_vdf_orders_v1.rb +12 -0
  78. data/vendor/vdf_shipping_v1/lib/sp_vdf_shipping_v1/api/customer_invoices_api.rb +152 -0
  79. data/vendor/vdf_shipping_v1/lib/sp_vdf_shipping_v1/api/vendor_shipping_api.rb +264 -0
  80. data/vendor/vdf_shipping_v1/lib/sp_vdf_shipping_v1/api/vendor_shipping_labels_api.rb +208 -0
  81. data/vendor/vdf_shipping_v1/lib/sp_vdf_shipping_v1.rb +14 -0
  82. data/vendor/vendor_invoices/lib/sp_vendor_invoices/api/vendor_payments_api.rb +77 -0
  83. data/vendor/vendor_invoices/lib/sp_vendor_invoices.rb +12 -0
  84. data/vendor/vendor_orders/lib/sp_vendor_orders/api/vendor_orders_api.rb +323 -0
  85. data/vendor/vendor_orders/lib/sp_vendor_orders.rb +12 -0
  86. data/vendor/vendor_transaction_status/lib/sp_vendor_transaction_status/api/vendor_transaction_api.rb +75 -0
  87. data/vendor/vendor_transaction_status/lib/sp_vendor_transaction_status.rb +12 -0
  88. data/vendor/vendors_shipments/lib/sp_vendors_shipments/api/vendor_shipping_api.rb +337 -0
  89. data/vendor/vendors_shipments/lib/sp_vendors_shipments.rb +12 -0
  90. metadata +321 -0
@@ -0,0 +1,106 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generated by lib/generator (bundle exec rake generate). Do not edit.
4
+
5
+ require 'amazon_sp_clients/v2/api'
6
+
7
+ module AmazonSpClients
8
+ module V2
9
+ # Selling Partner API for Retail Procurement Orders
10
+ #
11
+ # The Selling Partner API for Retail Procurement Orders provides programmatic access to vendor orders data.
12
+ #
13
+ # OpenAPI spec version: v1
14
+ class VendorOrders < Api
15
+ # Returns a purchase order based on the `purchaseOrderNumber` value that you specify. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 10 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
16
+ #
17
+ # @param purchase_order_number [String] The purchase order identifier for the order that you want. Formatting Notes: 8-character alpha-numeric code.
18
+ # @param rdt [Array<RDT::Resource>, nil] send a restricted data token for these resources
19
+ # @return [AmazonSpClients::ApiResponse]
20
+ def get_purchase_order(purchase_order_number, rdt: nil)
21
+ request(:get, "/vendor/orders/v1/purchaseOrders/#{encode(purchase_order_number)}", rdt: rdt)
22
+ end
23
+
24
+ # Returns a list of purchase orders created or changed during the time frame that you specify. You define the time frame using the `createdAfter`, `createdBefore`, `changedAfter` and `changedBefore` parameters. The date range to search must not be more than 7 days. You can choose to get only the purchase order numbers by setting `includeDetails` to false. You can then use the `getPurchaseOrder` operation to receive details for a specific purchase order. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 10 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
25
+ #
26
+ # @param limit [Integer, nil] The limit to the number of records returned. Default value is 100 records.
27
+ # @param created_after [String, nil] Purchase orders that became available after this time will be included in the result. Must be in ISO-8601 date/time format.
28
+ # @param created_before [String, nil] Purchase orders that became available before this time will be included in the result. Must be in ISO-8601 date/time format.
29
+ # @param sort_order [String, nil] Sort in ascending or descending order by purchase order creation date.
30
+ # @param next_token [String, nil] Used for pagination when there is more purchase orders than the specified result size limit. The token value is returned in the previous API call
31
+ # @param include_details [String, nil] When true, returns purchase orders with complete details. Otherwise, only purchase order numbers are returned. Default value is true.
32
+ # @param changed_after [String, nil] Purchase orders that changed after this timestamp will be included in the result. Must be in ISO-8601 date/time format.
33
+ # @param changed_before [String, nil] Purchase orders that changed before this timestamp will be included in the result. Must be in ISO-8601 date/time format.
34
+ # @param po_item_state [String, nil] Current state of the purchase order item. If this value is Cancelled, this API will return purchase orders which have one or more items cancelled by Amazon with updated item quantity as zero.
35
+ # @param is_po_changed [String, nil] When true, returns purchase orders which were modified after the order was placed. Vendors are required to pull the changed purchase order and fulfill the updated purchase order and not the original one. Default value is false.
36
+ # @param purchase_order_state [String, nil] Filters purchase orders based on the purchase order state.
37
+ # @param ordering_vendor_code [String, nil] Filters purchase orders based on the specified ordering vendor code. This value should be same as 'sellingParty.partyId' in the purchase order. If not included in the filter, all purchase orders for all of the vendor codes that exist in the vendor group used to authorize the API client application are returned.
38
+ # @param rdt [Array<RDT::Resource>, nil] send a restricted data token for these resources
39
+ # @return [AmazonSpClients::ApiResponse]
40
+ def get_purchase_orders(limit: nil, created_after: nil, created_before: nil, sort_order: nil, next_token: nil, include_details: nil, changed_after: nil, changed_before: nil, po_item_state: nil, is_po_changed: nil, purchase_order_state: nil, ordering_vendor_code: nil, rdt: nil)
41
+ query = {
42
+ 'limit' => limit,
43
+ 'createdAfter' => created_after,
44
+ 'createdBefore' => created_before,
45
+ 'sortOrder' => sort_order,
46
+ 'nextToken' => next_token,
47
+ 'includeDetails' => include_details,
48
+ 'changedAfter' => changed_after,
49
+ 'changedBefore' => changed_before,
50
+ 'poItemState' => po_item_state,
51
+ 'isPOChanged' => is_po_changed,
52
+ 'purchaseOrderState' => purchase_order_state,
53
+ 'orderingVendorCode' => ordering_vendor_code
54
+ }
55
+
56
+ request(:get, '/vendor/orders/v1/purchaseOrders', query: query, rdt: rdt)
57
+ end
58
+
59
+ # Returns purchase order statuses based on the filters that you specify. Date range to search must not be more than 7 days. You can return a list of purchase order statuses using the available filters, or a single purchase order status by providing the purchase order number. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 10 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
60
+ #
61
+ # @param limit [Integer, nil] The limit to the number of records returned. Default value is 100 records.
62
+ # @param sort_order [String, nil] Sort in ascending or descending order by purchase order creation date.
63
+ # @param next_token [String, nil] Used for pagination when there are more purchase orders than the specified result size limit.
64
+ # @param created_after [String, nil] Purchase orders that became available after this timestamp will be included in the result. Must be in ISO-8601 date/time format.
65
+ # @param created_before [String, nil] Purchase orders that became available before this timestamp will be included in the result. Must be in ISO-8601 date/time format.
66
+ # @param updated_after [String, nil] Purchase orders for which the last purchase order update happened after this timestamp will be included in the result. Must be in ISO-8601 date/time format.
67
+ # @param updated_before [String, nil] Purchase orders for which the last purchase order update happened before this timestamp will be included in the result. Must be in ISO-8601 date/time format.
68
+ # @param purchase_order_number [String, nil] Provides purchase order status for the specified purchase order number.
69
+ # @param purchase_order_status [String, nil] Filters purchase orders based on the specified purchase order status. If not included in filter, this will return purchase orders for all statuses.
70
+ # @param item_confirmation_status [String, nil] Filters purchase orders based on their item confirmation status. If the item confirmation status is not included in the filter, purchase orders for all confirmation statuses are included.
71
+ # @param item_receive_status [String, nil] Filters purchase orders based on the purchase order's item receive status. If the item receive status is not included in the filter, purchase orders for all receive statuses are included.
72
+ # @param ordering_vendor_code [String, nil] Filters purchase orders based on the specified ordering vendor code. This value should be same as 'sellingParty.partyId' in the purchase order. If not included in filter, all purchase orders for all the vendor codes that exist in the vendor group used to authorize API client application are returned.
73
+ # @param ship_to_party_id [String, nil] Filters purchase orders for a specific buyer's Fulfillment Center/warehouse by providing ship to location id here. This value should be same as 'shipToParty.partyId' in the purchase order. If not included in filter, this will return purchase orders for all the buyer's warehouses used for vendor group purchase orders.
74
+ # @param rdt [Array<RDT::Resource>, nil] send a restricted data token for these resources
75
+ # @return [AmazonSpClients::ApiResponse]
76
+ def get_purchase_orders_status(limit: nil, sort_order: nil, next_token: nil, created_after: nil, created_before: nil, updated_after: nil, updated_before: nil, purchase_order_number: nil, purchase_order_status: nil, item_confirmation_status: nil, item_receive_status: nil, ordering_vendor_code: nil, ship_to_party_id: nil, rdt: nil)
77
+ query = {
78
+ 'limit' => limit,
79
+ 'sortOrder' => sort_order,
80
+ 'nextToken' => next_token,
81
+ 'createdAfter' => created_after,
82
+ 'createdBefore' => created_before,
83
+ 'updatedAfter' => updated_after,
84
+ 'updatedBefore' => updated_before,
85
+ 'purchaseOrderNumber' => purchase_order_number,
86
+ 'purchaseOrderStatus' => purchase_order_status,
87
+ 'itemConfirmationStatus' => item_confirmation_status,
88
+ 'itemReceiveStatus' => item_receive_status,
89
+ 'orderingVendorCode' => ordering_vendor_code,
90
+ 'shipToPartyId' => ship_to_party_id
91
+ }
92
+
93
+ request(:get, '/vendor/orders/v1/purchaseOrdersStatus', query: query, rdt: rdt)
94
+ end
95
+
96
+ # Submits acknowledgements for one or more purchase orders. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 10 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
97
+ #
98
+ # @param body [Hash] Submits acknowledgements for one or more purchase orders from a vendor. (SubmitAcknowledgementRequest)
99
+ # @param rdt [Array<RDT::Resource>, nil] send a restricted data token for these resources
100
+ # @return [AmazonSpClients::ApiResponse]
101
+ def submit_acknowledgement(body, rdt: nil)
102
+ request(:post, '/vendor/orders/v1/acknowledgements', body: body, rdt: rdt)
103
+ end
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generated by lib/generator (bundle exec rake generate). Do not edit.
4
+
5
+ require 'amazon_sp_clients/v2/api'
6
+
7
+ module AmazonSpClients
8
+ module V2
9
+ # Selling Partner API for Retail Procurement Transaction Status
10
+ #
11
+ # The Selling Partner API for Retail Procurement Transaction Status provides programmatic access to status information on specific asynchronous POST transactions for vendors.
12
+ #
13
+ # OpenAPI spec version: v1
14
+ class VendorTransactionStatus < Api
15
+ # Returns the status of the transaction that you specify. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 20 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
16
+ #
17
+ # @param transaction_id [String] The GUID provided by Amazon in the 'transactionId' field in response to the post request of a specific transaction.
18
+ # @param rdt [Array<RDT::Resource>, nil] send a restricted data token for these resources
19
+ # @return [AmazonSpClients::ApiResponse]
20
+ def get_transaction(transaction_id, rdt: nil)
21
+ request(:get, "/vendor/transactions/v1/transactions/#{encode(transaction_id)}", rdt: rdt)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,120 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generated by lib/generator (bundle exec rake generate). Do not edit.
4
+
5
+ require 'amazon_sp_clients/v2/api'
6
+
7
+ module AmazonSpClients
8
+ module V2
9
+ # Selling Partner API for Retail Procurement Shipments
10
+ #
11
+ # The Selling Partner API for Retail Procurement Shipments provides programmatic access to retail shipping data for vendors.
12
+ #
13
+ # OpenAPI spec version: v1
14
+ class VendorsShipments < Api
15
+ # GetShipmentDetails
16
+ #
17
+ # @param limit [Integer, nil] The limit to the number of records returned. Default value is 50 records.
18
+ # @param sort_order [String, nil] Sort in ascending or descending order by purchase order creation date.
19
+ # @param next_token [String, nil] Used for pagination when there are more shipments than the specified result size limit.
20
+ # @param created_after [String, nil] Get Shipment Details that became available after this timestamp will be included in the result. Must be in <a href='https://developer-docs.amazon.com/sp-api/docs/iso-8601'>ISO 8601</a> format.
21
+ # @param created_before [String, nil] Get Shipment Details that became available before this timestamp will be included in the result. Must be in <a href='https://developer-docs.amazon.com/sp-api/docs/iso-8601'>ISO 8601</a> format.
22
+ # @param shipment_confirmed_before [String, nil] Get Shipment Details by passing Shipment confirmed create Date Before. Must be in <a href='https://developer-docs.amazon.com/sp-api/docs/iso-8601'>ISO 8601</a> format.
23
+ # @param shipment_confirmed_after [String, nil] Get Shipment Details by passing Shipment confirmed create Date After. Must be in <a href='https://developer-docs.amazon.com/sp-api/docs/iso-8601'>ISO 8601</a> format.
24
+ # @param package_label_created_before [String, nil] Get Shipment Details by passing Package label create Date by buyer. Must be in <a href='https://developer-docs.amazon.com/sp-api/docs/iso-8601'>ISO 8601</a> format.
25
+ # @param package_label_created_after [String, nil] Get Shipment Details by passing Package label create Date After by buyer. Must be in <a href='https://developer-docs.amazon.com/sp-api/docs/iso-8601'>ISO 8601</a> format.
26
+ # @param shipped_before [String, nil] Get Shipment Details by passing Shipped Date Before. Must be in <a href='https://developer-docs.amazon.com/sp-api/docs/iso-8601'>ISO 8601</a> format.
27
+ # @param shipped_after [String, nil] Get Shipment Details by passing Shipped Date After. Must be in <a href='https://developer-docs.amazon.com/sp-api/docs/iso-8601'>ISO 8601</a> format.
28
+ # @param estimated_delivery_before [String, nil] Get Shipment Details by passing Estimated Delivery Date Before. Must be in <a href='https://developer-docs.amazon.com/sp-api/docs/iso-8601'>ISO 8601</a> format.
29
+ # @param estimated_delivery_after [String, nil] Get Shipment Details by passing Estimated Delivery Date Before. Must be in <a href='https://developer-docs.amazon.com/sp-api/docs/iso-8601'>ISO 8601</a> format.
30
+ # @param shipment_delivery_before [String, nil] Get Shipment Details by passing Shipment Delivery Date Before. Must be in <a href='https://developer-docs.amazon.com/sp-api/docs/iso-8601'>ISO 8601</a> format.
31
+ # @param shipment_delivery_after [String, nil] Get Shipment Details by passing Shipment Delivery Date After. Must be in <a href='https://developer-docs.amazon.com/sp-api/docs/iso-8601'>ISO 8601</a> format.
32
+ # @param requested_pick_up_before [String, nil] Get Shipment Details by passing Before Requested pickup date. Must be in <a href='https://developer-docs.amazon.com/sp-api/docs/iso-8601'>ISO 8601</a> format.
33
+ # @param requested_pick_up_after [String, nil] Get Shipment Details by passing After Requested pickup date. Must be in <a href='https://developer-docs.amazon.com/sp-api/docs/iso-8601'>ISO 8601</a> format.
34
+ # @param scheduled_pick_up_before [String, nil] Get Shipment Details by passing Before scheduled pickup date. Must be in <a href='https://developer-docs.amazon.com/sp-api/docs/iso-8601'>ISO 8601</a> format.
35
+ # @param scheduled_pick_up_after [String, nil] Get Shipment Details by passing After Scheduled pickup date. Must be in <a href='https://developer-docs.amazon.com/sp-api/docs/iso-8601'>ISO 8601</a> format.
36
+ # @param current_shipment_status [String, nil] Get Shipment Details by passing Current shipment status.
37
+ # @param vendor_shipment_identifier [String, nil] Get Shipment Details by passing Vendor Shipment ID
38
+ # @param buyer_reference_number [String, nil] Get Shipment Details by passing buyer Reference ID
39
+ # @param buyer_warehouse_code [String, nil] Get Shipping Details based on buyer warehouse code. This value should be same as 'shipToParty.partyId' in the Shipment.
40
+ # @param seller_warehouse_code [String, nil] Get Shipping Details based on vendor warehouse code. This value should be same as 'sellingParty.partyId' in the Shipment.
41
+ # @param rdt [Array<RDT::Resource>, nil] send a restricted data token for these resources
42
+ # @return [AmazonSpClients::ApiResponse]
43
+ def get_shipment_details(limit: nil, sort_order: nil, next_token: nil, created_after: nil, created_before: nil, shipment_confirmed_before: nil, shipment_confirmed_after: nil, package_label_created_before: nil, package_label_created_after: nil, shipped_before: nil, shipped_after: nil, estimated_delivery_before: nil, estimated_delivery_after: nil, shipment_delivery_before: nil, shipment_delivery_after: nil, requested_pick_up_before: nil, requested_pick_up_after: nil, scheduled_pick_up_before: nil, scheduled_pick_up_after: nil, current_shipment_status: nil, vendor_shipment_identifier: nil, buyer_reference_number: nil, buyer_warehouse_code: nil, seller_warehouse_code: nil, rdt: nil)
44
+ query = {
45
+ 'limit' => limit,
46
+ 'sortOrder' => sort_order,
47
+ 'nextToken' => next_token,
48
+ 'createdAfter' => created_after,
49
+ 'createdBefore' => created_before,
50
+ 'shipmentConfirmedBefore' => shipment_confirmed_before,
51
+ 'shipmentConfirmedAfter' => shipment_confirmed_after,
52
+ 'packageLabelCreatedBefore' => package_label_created_before,
53
+ 'packageLabelCreatedAfter' => package_label_created_after,
54
+ 'shippedBefore' => shipped_before,
55
+ 'shippedAfter' => shipped_after,
56
+ 'estimatedDeliveryBefore' => estimated_delivery_before,
57
+ 'estimatedDeliveryAfter' => estimated_delivery_after,
58
+ 'shipmentDeliveryBefore' => shipment_delivery_before,
59
+ 'shipmentDeliveryAfter' => shipment_delivery_after,
60
+ 'requestedPickUpBefore' => requested_pick_up_before,
61
+ 'requestedPickUpAfter' => requested_pick_up_after,
62
+ 'scheduledPickUpBefore' => scheduled_pick_up_before,
63
+ 'scheduledPickUpAfter' => scheduled_pick_up_after,
64
+ 'currentShipmentStatus' => current_shipment_status,
65
+ 'vendorShipmentIdentifier' => vendor_shipment_identifier,
66
+ 'buyerReferenceNumber' => buyer_reference_number,
67
+ 'buyerWarehouseCode' => buyer_warehouse_code,
68
+ 'sellerWarehouseCode' => seller_warehouse_code
69
+ }
70
+
71
+ request(:get, '/vendor/shipping/v1/shipments', query: query, rdt: rdt)
72
+ end
73
+
74
+ # Returns small parcel shipment labels based on the filters that you specify. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 10 | The `x-amzn-RateLimit-Limit` response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
75
+ #
76
+ # @param limit [Integer, nil] The limit to the number of records returned. Default value is 50 records.
77
+ # @param sort_order [String, nil] Sort the list by shipment label creation date in ascending or descending order.
78
+ # @param next_token [String, nil] A token that is used to retrieve the next page of results. The response includes `nextToken` when the number of results exceeds the specified `pageSize` value. To get the next page of results, call the operation with this token and include the same arguments as the call that produced the token. To get a complete list, call this operation until `nextToken` is null. Note that this operation can return empty pages.
79
+ # @param label_created_after [String, nil] Shipment labels created after this time will be included in the result. This field must be in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) datetime format.
80
+ # @param label_created_before [String, nil] Shipment labels created before this time will be included in the result. This field must be in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) datetime format.
81
+ # @param buyer_reference_number [String, nil] Get Shipment labels by passing buyer reference number.
82
+ # @param vendor_shipment_identifier [String, nil] Get Shipment labels by passing vendor shipment identifier.
83
+ # @param seller_warehouse_code [String, nil] Get Shipping labels based on vendor warehouse code. This value must be same as the `sellingParty.partyId` in the shipment.
84
+ # @param rdt [Array<RDT::Resource>, nil] send a restricted data token for these resources
85
+ # @return [AmazonSpClients::ApiResponse]
86
+ def get_shipment_labels(limit: nil, sort_order: nil, next_token: nil, label_created_after: nil, label_created_before: nil, buyer_reference_number: nil, vendor_shipment_identifier: nil, seller_warehouse_code: nil, rdt: nil)
87
+ query = {
88
+ 'limit' => limit,
89
+ 'sortOrder' => sort_order,
90
+ 'nextToken' => next_token,
91
+ 'labelCreatedAfter' => label_created_after,
92
+ 'labelCreatedBefore' => label_created_before,
93
+ 'buyerReferenceNumber' => buyer_reference_number,
94
+ 'vendorShipmentIdentifier' => vendor_shipment_identifier,
95
+ 'sellerWarehouseCode' => seller_warehouse_code
96
+ }
97
+
98
+ request(:get, '/vendor/shipping/v1/transportLabels', query: query, rdt: rdt)
99
+ end
100
+
101
+ # SubmitShipmentConfirmations
102
+ #
103
+ # @param body [Hash] A request to submit shipment confirmation. (SubmitShipmentConfirmationsRequest)
104
+ # @param rdt [Array<RDT::Resource>, nil] send a restricted data token for these resources
105
+ # @return [AmazonSpClients::ApiResponse]
106
+ def submit_shipment_confirmations(body, rdt: nil)
107
+ request(:post, '/vendor/shipping/v1/shipmentConfirmations', body: body, rdt: rdt)
108
+ end
109
+
110
+ # SubmitShipments
111
+ #
112
+ # @param body [Hash] A request to submit shipment request. (SubmitShipments)
113
+ # @param rdt [Array<RDT::Resource>, nil] send a restricted data token for these resources
114
+ # @return [AmazonSpClients::ApiResponse]
115
+ def submit_shipments(body, rdt: nil)
116
+ request(:post, '/vendor/shipping/v1/shipments', body: body, rdt: rdt)
117
+ end
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generated by lib/generator (bundle exec rake generate). Do not edit.
4
+
5
+ require 'amazon_sp_clients/v2/client'
6
+
7
+ module AmazonSpClients
8
+ module V2
9
+ autoload :FbaInventory, 'amazon_sp_clients/v2/apis/fba_inventory'
10
+ autoload :Feeds2021, 'amazon_sp_clients/v2/apis/feeds_2021'
11
+ autoload :FulfillmentOutbound2020, 'amazon_sp_clients/v2/apis/fulfillment_outbound_2020'
12
+ autoload :ListingsItems2021, 'amazon_sp_clients/v2/apis/listings_items_2021'
13
+ autoload :OrdersV0, 'amazon_sp_clients/v2/apis/orders_v0'
14
+ autoload :Reports2021, 'amazon_sp_clients/v2/apis/reports_2021'
15
+ autoload :Tokens2021, 'amazon_sp_clients/v2/apis/tokens_2021'
16
+ autoload :VdfInventoryV1, 'amazon_sp_clients/v2/apis/vdf_inventory_v1'
17
+ autoload :VdfOrdersV1, 'amazon_sp_clients/v2/apis/vdf_orders_v1'
18
+ autoload :VdfShippingV1, 'amazon_sp_clients/v2/apis/vdf_shipping_v1'
19
+ autoload :VendorInvoices, 'amazon_sp_clients/v2/apis/vendor_invoices'
20
+ autoload :VendorOrders, 'amazon_sp_clients/v2/apis/vendor_orders'
21
+ autoload :VendorTransactionStatus, 'amazon_sp_clients/v2/apis/vendor_transaction_status'
22
+ autoload :VendorsShipments, 'amazon_sp_clients/v2/apis/vendors_shipments'
23
+
24
+ class Client
25
+ # Selling Partner API for FBA Inventory
26
+ # @return [FbaInventory]
27
+ def fba_inventory = api(FbaInventory)
28
+
29
+ # Selling Partner API for Feeds
30
+ # @return [Feeds2021]
31
+ def feeds_2021 = api(Feeds2021)
32
+
33
+ # Selling Partner APIs for Fulfillment Outbound
34
+ # @return [FulfillmentOutbound2020]
35
+ def fulfillment_outbound_2020 = api(FulfillmentOutbound2020)
36
+
37
+ # Selling Partner API for Listings Items
38
+ # @return [ListingsItems2021]
39
+ def listings_items_2021 = api(ListingsItems2021)
40
+
41
+ # Selling Partner API for Orders
42
+ # @return [OrdersV0]
43
+ def orders_v0 = api(OrdersV0)
44
+
45
+ # Selling Partner API for Reports
46
+ # @return [Reports2021]
47
+ def reports_2021 = api(Reports2021)
48
+
49
+ # Selling Partner API for Tokens
50
+ # @return [Tokens2021]
51
+ def tokens_2021 = api(Tokens2021)
52
+
53
+ # Selling Partner API for Direct Fulfillment Inventory Updates
54
+ # @return [VdfInventoryV1]
55
+ def vdf_inventory_v1 = api(VdfInventoryV1)
56
+
57
+ # Selling Partner API for Direct Fulfillment Orders
58
+ # @return [VdfOrdersV1]
59
+ def vdf_orders_v1 = api(VdfOrdersV1)
60
+
61
+ # Selling Partner API for Direct Fulfillment Shipping
62
+ # @return [VdfShippingV1]
63
+ def vdf_shipping_v1 = api(VdfShippingV1)
64
+
65
+ # Selling Partner API for Retail Procurement Payments
66
+ # @return [VendorInvoices]
67
+ def vendor_invoices = api(VendorInvoices)
68
+
69
+ # Selling Partner API for Retail Procurement Orders
70
+ # @return [VendorOrders]
71
+ def vendor_orders = api(VendorOrders)
72
+
73
+ # Selling Partner API for Retail Procurement Transaction Status
74
+ # @return [VendorTransactionStatus]
75
+ def vendor_transaction_status = api(VendorTransactionStatus)
76
+
77
+ # Selling Partner API for Retail Procurement Shipments
78
+ # @return [VendorsShipments]
79
+ def vendors_shipments = api(VendorsShipments)
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,198 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'faraday'
5
+ require 'amazon_sp_clients/adapter_loader'
6
+ require 'amazon_sp_clients/api_response'
7
+ require 'amazon_sp_clients/v2/config'
8
+ require 'amazon_sp_clients/v2/credentials'
9
+ require 'amazon_sp_clients/v2/documents'
10
+ require 'amazon_sp_clients/v2/errors'
11
+ require 'amazon_sp_clients/v2/error_mapper'
12
+ require 'amazon_sp_clients/v2/lwa'
13
+ require 'amazon_sp_clients/v2/rdt'
14
+ require 'amazon_sp_clients/v2/token'
15
+
16
+ module AmazonSpClients
17
+ module V2
18
+ # One client per merchant. Owns the connection, the token source and
19
+ # the restricted-token cache, and hands out one instance of each API
20
+ # class. Safe to share across threads.
21
+ #
22
+ # client = Client.new(config) { store.access_token }
23
+ # client.orders_v0.get_orders(marketplace_ids, created_after: since)
24
+ class Client
25
+ # Tokens API operation that issues restricted data tokens.
26
+ TOKENS_PATH = '/tokens/2021-03-01/restrictedDataToken'
27
+ # Carries the access token (or the restricted data token).
28
+ ACCESS_TOKEN_HEADER = 'x-amz-access-token'
29
+ # Request timestamp Amazon asks for on every call.
30
+ DATE_HEADER = 'x-amz-date'
31
+ # Format of DATE_HEADER.
32
+ DATE_FORMAT = '%Y%m%dT%H%M%SZ'
33
+ # Request and response media type of every SP-API operation.
34
+ JSON_TYPE = 'application/json'
35
+
36
+ # @return [Config]
37
+ attr_reader :config
38
+
39
+ # @param config [Config]
40
+ # @param credentials [#access_token, nil] the token source; or pass a block
41
+ # @yieldreturn [String] the current access token (see Credentials::Callback)
42
+ # @raise [ArgumentError] unless exactly one token source is given
43
+ def initialize(config, credentials: nil, &token)
44
+ if credentials.nil? == token.nil?
45
+ raise ArgumentError, 'give credentials: or a block returning the access token'
46
+ end
47
+
48
+ @config = config
49
+ @credentials = credentials || Credentials::Callback.new(&token)
50
+ @errors = ErrorMapper.new(:api)
51
+ @api = build_connection
52
+ @documents = Documents.new(config)
53
+ @rdt = RDT::Cache.new
54
+ @apis = {}
55
+ @apis_mutex = Mutex.new
56
+ end
57
+
58
+ # A client that exchanges +refresh_token+ through LWA itself, using
59
+ # the app credentials on +config+.
60
+ #
61
+ # @param config [Config] with client_id and client_secret
62
+ # @param refresh_token [String]
63
+ # @return [Client]
64
+ def self.with_refresh_token(config, refresh_token)
65
+ new(config, credentials: Credentials::RefreshToken.new(LWA.new(config), refresh_token))
66
+ end
67
+
68
+ # One instance of each API class per client, so they all share the
69
+ # connection.
70
+ #
71
+ # @param klass [Class] an Api subclass
72
+ # @return [Api]
73
+ def api(klass)
74
+ @apis_mutex.synchronize { @apis[klass] ||= klass.new(self) }
75
+ end
76
+
77
+ # Sends one request and returns the parsed response. The generated
78
+ # API classes call this; consumers use them.
79
+ #
80
+ # @param method [Symbol] :get, :post, :put, :patch, :delete
81
+ # @param path [String] request path, already percent-encoded
82
+ # @param query [Hash] query parameters; nil values are left out
83
+ # @param headers [Hash] extra request headers; nil values are left out
84
+ # @param body [Hash, Array, String, nil] sent through to_json unless already a String
85
+ # @param rdt [Array<RDT::Resource>, nil] send a restricted data token for these
86
+ # resources; nil or empty sends the normal access token
87
+ # @return [AmazonSpClients::ApiResponse]
88
+ # @raise [Error] a ResponseError subclass on a non-2xx status, ConnectionError or
89
+ # TimeoutError when no response arrived, ParseError on a non-JSON body
90
+ def request(method, path, query: {}, headers: {}, body: nil, rdt: nil)
91
+ token = restricted?(rdt) ? restricted_token(rdt) : @credentials.access_token
92
+ all_headers = headers.compact.merge(auth_headers(token))
93
+ response = send_request(method, path, query, all_headers, body)
94
+
95
+ ApiResponse.new(parse(response), response)
96
+ end
97
+
98
+ # Uploads feed content to the presigned url of a feed document.
99
+ #
100
+ # @param document [Hash] payload of createFeedDocument
101
+ # @param content_type [String] the one given to createFeedDocument
102
+ # @param body [String] feed content
103
+ # @return [nil]
104
+ # @see Documents#upload
105
+ def upload_feed_document(document, content_type, body)
106
+ @documents.upload(document, content_type, body)
107
+ end
108
+
109
+ # Downloads and parses the processing report of a feed.
110
+ #
111
+ # @param document [Hash] payload of getFeedDocument
112
+ # @return [Hash] string-keyed
113
+ # @see Documents#download_feed_result
114
+ def download_feed_result(document)
115
+ @documents.download_feed_result(document)
116
+ end
117
+
118
+ # Downloads a report document, inflating it when gzipped.
119
+ #
120
+ # @param document [Hash] payload of getReportDocument
121
+ # @return [String]
122
+ # @see Documents#download_report_document
123
+ def download_report_document(document)
124
+ @documents.download_report_document(document)
125
+ end
126
+
127
+ private
128
+
129
+ def build_connection
130
+ options = { timeout: @config.timeout, open_timeout: @config.open_timeout }
131
+ headers = {
132
+ 'User-Agent' => @config.user_agent, 'Content-Type' => JSON_TYPE, 'Accept' => JSON_TYPE
133
+ }
134
+
135
+ Faraday.new(url: @config.base_url, request: options, headers: headers) do |conn|
136
+ conn.adapter Faraday::Adapter::HTTPClient
137
+ end
138
+ end
139
+
140
+ def auth_headers(token)
141
+ { ACCESS_TOKEN_HEADER => token, DATE_HEADER => Time.now.utc.strftime(DATE_FORMAT) }
142
+ end
143
+
144
+ def send_request(method, path, query, headers, body)
145
+ response = @api.run_request(method, path, encode(body), headers) do |req|
146
+ req.params.update(query.compact)
147
+ end
148
+
149
+ @errors.check!(response)
150
+ rescue *ErrorMapper::TRANSPORT_ERRORS => e
151
+ raise @errors.transport_error(e, method: method, url: "#{@config.base_url}#{path}")
152
+ end
153
+
154
+ # The body's own to_json, not JSON.generate: ActiveSupport's encoder
155
+ # (ISO 8601 times) only runs through to_json, and v1 called it too.
156
+ def encode(body)
157
+ return body if body.nil? || body.is_a?(String)
158
+
159
+ body.to_json
160
+ end
161
+
162
+ def parse(response)
163
+ body = response.body
164
+ return {} if body.nil? || body.empty?
165
+
166
+ parsed = JSON.parse(body, symbolize_names: true)
167
+ parsed.is_a?(Hash) ? parsed : { payload: parsed }
168
+ rescue JSON::ParserError => e
169
+ raise @errors.parse_error("response body is not JSON: #{e.message}", response)
170
+ end
171
+
172
+ def restricted?(rdt)
173
+ !(rdt.nil? || rdt.empty?)
174
+ end
175
+
176
+ # The Tokens API call inside the fetch goes out with the normal
177
+ # access token (no rdt:), so it never comes back to the cache lock
178
+ # that is held around it. Lock order is cache, then credentials.
179
+ def restricted_token(resources)
180
+ @rdt.fetch(resources) { fetch_restricted_token(resources) }
181
+ end
182
+
183
+ def fetch_restricted_token(resources)
184
+ body = { restrictedResources: Array(resources).map(&:to_request) }
185
+ response = request(:post, TOKENS_PATH, body: body)
186
+ payload = response.payload
187
+ token = payload[:restrictedDataToken]
188
+ unless token
189
+ raise @errors.parse_error('token response has no restrictedDataToken', response.response)
190
+ end
191
+
192
+ expires_in = payload[:expiresIn]
193
+ Token.new(access_token: token, token_type: nil, expires_in: expires_in,
194
+ expires_at: expires_in && (Time.now.utc + expires_in), refresh_token: nil)
195
+ end
196
+ end
197
+ end
198
+ end
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'amazon_sp_clients/version'
4
+ require 'amazon_sp_clients/marketplaces'
5
+ require 'amazon_sp_clients/v2/errors'
6
+
7
+ module AmazonSpClients
8
+ module V2
9
+ # Per-client settings: which SP-API host to talk to, timeouts, the
10
+ # user agent, and the LWA app credentials (only needed by clients
11
+ # that exchange refresh tokens themselves). Frozen; build a variant
12
+ # with +with+:
13
+ #
14
+ # config = Config.new(endpoint: 'eu', sandbox: true)
15
+ # config.with(sandbox: false)
16
+ Config = Data.define(:endpoint, :sandbox, :timeout, :open_timeout,
17
+ :client_id, :client_secret, :user_agent)
18
+
19
+ class Config
20
+ # Endpoint codes consumers store per merchant, mapped to the AWS
21
+ # region that names the SP-API host. Same table as v1's
22
+ # Configuration#endpoint=.
23
+ ENDPOINT_REGIONS = {
24
+ 'na' => REGION_NA, 'br' => REGION_NA, 'ca' => REGION_NA, 'mx' => REGION_NA,
25
+ 'us' => REGION_NA,
26
+ 'fe' => REGION_FE, 'au' => REGION_FE, 'jp' => REGION_FE, 'sg' => REGION_FE,
27
+ 'eu' => REGION_EU, 'ae' => REGION_EU, 'de' => REGION_EU, 'eg' => REGION_EU,
28
+ 'es' => REGION_EU, 'fr' => REGION_EU, 'gb' => REGION_EU, 'in' => REGION_EU,
29
+ 'it' => REGION_EU, 'nl' => REGION_EU, 'pl' => REGION_EU, 'sa' => REGION_EU,
30
+ 'se' => REGION_EU, 'tr' => REGION_EU
31
+ }.freeze
32
+
33
+ # North America, where every consumer started.
34
+ DEFAULT_ENDPOINT = 'na'
35
+ # Seconds to read or write on an open connection.
36
+ DEFAULT_TIMEOUT = 60
37
+ # Seconds to open a connection.
38
+ DEFAULT_OPEN_TIMEOUT = 10
39
+ # Names the gem and Ruby version, as Amazon asks.
40
+ DEFAULT_USER_AGENT = "sp_api_clients/#{VERSION} (Language=Ruby/#{RUBY_VERSION})".freeze
41
+ # Host prefix of the SP-API sandbox.
42
+ SANDBOX_PREFIX = 'sandbox.'
43
+
44
+ # @param endpoint [String] region or country code ('na', 'eu', 'fe', 'de', ...)
45
+ # @param sandbox [Boolean] send requests to the sandbox host
46
+ # @param timeout [Integer] read/write timeout in seconds
47
+ # @param open_timeout [Integer] connect timeout in seconds
48
+ # @param client_id [String, nil] LWA app client id
49
+ # @param client_secret [String, nil] LWA app client secret
50
+ # @param user_agent [String, nil] nil selects the default
51
+ # @raise [ArgumentError] on an unknown endpoint code
52
+ def initialize(endpoint: DEFAULT_ENDPOINT, sandbox: false, timeout: DEFAULT_TIMEOUT,
53
+ open_timeout: DEFAULT_OPEN_TIMEOUT, client_id: nil, client_secret: nil,
54
+ user_agent: DEFAULT_USER_AGENT)
55
+ ENDPOINT_REGIONS.fetch(endpoint) do
56
+ raise ArgumentError, "unknown endpoint #{endpoint.inspect}"
57
+ end
58
+
59
+ super(endpoint: endpoint, sandbox: sandbox, timeout: timeout, open_timeout: open_timeout,
60
+ client_id: client_id, client_secret: client_secret,
61
+ user_agent: user_agent || DEFAULT_USER_AGENT)
62
+ end
63
+
64
+ # @return [String] AWS region of the endpoint, e.g. 'us-east-1'
65
+ def region = ENDPOINT_REGIONS.fetch(endpoint)
66
+
67
+ # @return [String] SP-API host, with the sandbox prefix when enabled
68
+ def host
69
+ "#{SANDBOX_PREFIX if sandbox}#{REGIONS.fetch(region)}"
70
+ end
71
+
72
+ # @return [String] base URL of every API request
73
+ def base_url = "https://#{host}"
74
+
75
+ # Consoles and error trackers inspect configs; the secret stays out.
76
+ #
77
+ # @return [String]
78
+ def inspect
79
+ fields = to_h.merge(client_secret: client_secret && FILTERED)
80
+
81
+ "#<#{self.class.name} #{fields.map { |k, v| "#{k}=#{v.inspect}" }.join(' ')}>"
82
+ end
83
+ end
84
+ end
85
+ end