postmen 0.1.0 → 1.0.0.pre.alpha.1
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.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/lib/postmen/collection_proxy.rb +22 -0
- data/lib/postmen/connection.rb +44 -0
- data/lib/postmen/label.rb +15 -0
- data/lib/postmen/label_collection.rb +19 -0
- data/lib/postmen/manifest.rb +38 -0
- data/lib/postmen/manifest_collection.rb +39 -0
- data/lib/postmen/parcel.rb +12 -0
- data/lib/postmen/query/create_label_query.rb +6 -1
- data/lib/postmen/query/create_manifest_query.rb +23 -0
- data/lib/postmen/query/create_rate_query.rb +27 -0
- data/lib/postmen/query/create_shipper_account_query.rb +22 -0
- data/lib/postmen/query/label_query.rb +7 -1
- data/lib/postmen/query/manifest_query.rb +50 -0
- data/lib/postmen/query/rate_query.rb +41 -0
- data/lib/postmen/query/shipper_account_query.rb +29 -0
- data/lib/postmen/query/shipper_account_update_credentials_query.rb +20 -0
- data/lib/postmen/query/shipper_account_update_query.rb +30 -0
- data/lib/postmen/rate.rb +35 -0
- data/lib/postmen/rate_collection.rb +39 -0
- data/lib/postmen/rate_object.rb +19 -0
- data/lib/postmen/response.rb +20 -0
- data/lib/postmen/shipment.rb +18 -0
- data/lib/postmen/shipper_account.rb +68 -0
- data/lib/postmen/shipper_account_collection.rb +39 -0
- data/lib/postmen/types/address.rb +31 -0
- data/lib/postmen/types/aes.rb +11 -0
- data/lib/postmen/types/billing.rb +9 -0
- data/lib/postmen/types/brief_shipper_account.rb +12 -0
- data/lib/postmen/types/customs.rb +16 -0
- data/lib/postmen/types/customs_billing.rb +13 -0
- data/lib/postmen/types/detailed_charges.rb +10 -0
- data/lib/postmen/types/dimension.rb +12 -0
- data/lib/postmen/types/invoice.rb +9 -0
- data/lib/postmen/types/item.rb +24 -0
- data/lib/postmen/types/money.rb +10 -0
- data/lib/postmen/types/no_eei.rb +11 -0
- data/lib/postmen/types/passport.rb +21 -0
- data/lib/postmen/types/payment_method.rb +13 -0
- data/lib/postmen/types/reference.rb +9 -0
- data/lib/postmen/types/uuid.rb +10 -0
- data/lib/postmen/types/weight.rb +10 -0
- data/lib/postmen/types.rb +113 -8
- data/lib/postmen/version.rb +2 -1
- data/lib/postmen.rb +36 -1
- metadata +71 -9
@@ -0,0 +1,39 @@
|
|
1
|
+
class Postmen
|
2
|
+
# This class wraps the array of Rate models
|
3
|
+
class RateCollection
|
4
|
+
include CollectionProxy
|
5
|
+
|
6
|
+
model Rate
|
7
|
+
key :rates
|
8
|
+
|
9
|
+
# Fetch all rates.
|
10
|
+
#
|
11
|
+
# @param options [Hash] Options for the query.
|
12
|
+
# @see https://docs.postmen.com/api.html#rates-list-all-rates API documentation
|
13
|
+
# @example
|
14
|
+
# .all # Returns all rates, default query.
|
15
|
+
# .all(status: :failed) # Returns only failed rates
|
16
|
+
def self.all(options = {})
|
17
|
+
new(Connection.new.get('/rates', RateQuery.new(options).to_query).parsed_response)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Fetch single rate
|
21
|
+
#
|
22
|
+
# @param id [UUID] Rate UUID
|
23
|
+
# @see https://docs.postmen.com/api.html#rates-calculate-rates API documentation
|
24
|
+
# @return [Rate]
|
25
|
+
# @raise ResourceNotFound if Rate with given id was not found
|
26
|
+
def self.find(id)
|
27
|
+
get(Connection.new.get("/rates/#{id}").parsed_response)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Creates a Rate
|
31
|
+
#
|
32
|
+
# @param params [Hash] Rate params
|
33
|
+
# @see https://docs.postmen.com/api.html#labels-create-a-label API documentation
|
34
|
+
# @return [Rate]
|
35
|
+
def self.create(params)
|
36
|
+
Rate.new(Connection.new.post('/rates', CreateRateQuery.new(params).to_query).parsed_response[:data])
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Postmen
|
2
|
+
# Rate record object
|
3
|
+
#
|
4
|
+
# @see https://docs.postmen.com/api.html#rates API documentation
|
5
|
+
class RateObject < Dry::Struct
|
6
|
+
attribute :shipper_account, Types::BriefShipperAccount
|
7
|
+
attribute :service_type, Types::String
|
8
|
+
attribute :service_name, Types::String
|
9
|
+
attribute :charge_weight, Types::Weight
|
10
|
+
attribute :total_charge, Types::Money
|
11
|
+
attribute :pickup_deadline, Types::String
|
12
|
+
attribute :booking_cut_off, Types::Date
|
13
|
+
attribute :delivery_date, Types::String
|
14
|
+
attribute :transit_time, Types::String
|
15
|
+
attribute :detailed_charges, Types::Array.member(Types::DetailedCharges)
|
16
|
+
attribute :info_message, Types::String
|
17
|
+
attribute :error_message, Types::String
|
18
|
+
end
|
19
|
+
end
|
data/lib/postmen/response.rb
CHANGED
@@ -1,44 +1,64 @@
|
|
1
1
|
class Postmen
|
2
|
+
# This class parses the HTTP response and checks if it was successfull.
|
2
3
|
class Response < SimpleDelegator
|
4
|
+
# Parses response.
|
5
|
+
# Ensures that rate limit was not exceeded,
|
6
|
+
# and checks if resource was found
|
3
7
|
def parse_response!
|
4
8
|
ensure_rate_limit!
|
5
9
|
ensure_resource_found!
|
6
10
|
end
|
7
11
|
|
12
|
+
# Holds the meta data
|
13
|
+
# @see https://docs.postmen.com/#meta API Documentation
|
14
|
+
# @return [Hash]
|
8
15
|
def meta
|
9
16
|
@meta ||= parsed_response[:meta]
|
10
17
|
end
|
11
18
|
|
19
|
+
# Parses the json response
|
20
|
+
# @return [Hash]
|
12
21
|
def parsed_response
|
13
22
|
@parsed_response ||= JSON.parse(body, symbolize_names: true)
|
14
23
|
end
|
15
24
|
|
25
|
+
# Checks if rate limit was exceeded
|
16
26
|
def rate_limit_exceeded?
|
17
27
|
code == 429
|
18
28
|
end
|
19
29
|
|
30
|
+
# Returns number of remaining API calls
|
20
31
|
def remaining_api_calls
|
21
32
|
Integer(headers['X-RateLimit-Remaining'])
|
22
33
|
end
|
23
34
|
|
35
|
+
# Returns current API rate limit
|
24
36
|
def api_rate_limit
|
25
37
|
Integer(headers['X-RateLimit-Limit'])
|
26
38
|
end
|
27
39
|
|
40
|
+
# Returns Unix timestamp when rate limit will be reset.
|
41
|
+
# @return [Integer] timestamp
|
28
42
|
def api_rate_limit_reset
|
29
43
|
Integer(headers['X-RateLimit-Reset'])
|
30
44
|
end
|
31
45
|
|
46
|
+
# Return time when rate limit will be reset.
|
47
|
+
# @return [Time]
|
32
48
|
def api_rate_limit_reset_at
|
33
49
|
Time.at(api_rate_limit_reset)
|
34
50
|
end
|
35
51
|
|
36
52
|
private
|
37
53
|
|
54
|
+
# Guard method, checking if rate limit was not exceeded
|
55
|
+
# @api private
|
38
56
|
def ensure_rate_limit!
|
39
57
|
raise RateLimitExceeded, self if rate_limit_exceeded?
|
40
58
|
end
|
41
59
|
|
60
|
+
# Guard method, checking if resource was found.
|
61
|
+
# @api private
|
42
62
|
def ensure_resource_found!
|
43
63
|
raise ResourceNotFound, self if meta[:code] == 4153
|
44
64
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Postmen
|
2
|
+
# Shipment object
|
3
|
+
#
|
4
|
+
# @see https://docs.postmen.com/api.html#shipment API documentation
|
5
|
+
class Shipment < Dry::Struct
|
6
|
+
constructor_type :strict_with_defaults
|
7
|
+
|
8
|
+
attribute :ship_from, Types::Address
|
9
|
+
attribute :ship_to, Types::Address
|
10
|
+
attribute :parcels, Types::Array.member(Parcel)
|
11
|
+
|
12
|
+
# Converts object to hash
|
13
|
+
# @return [Hash]
|
14
|
+
def to_hash
|
15
|
+
super.reject { |_k, v| v.nil? }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
class Postmen
|
2
|
+
# Shipper account object
|
3
|
+
# (brief information for rate and manifest responses)
|
4
|
+
# @see https://docs.postmen.com/api.html#shipper-account-information API Documentation
|
5
|
+
class ShipperAccount < Dry::Struct
|
6
|
+
attribute :id, Types::UUID
|
7
|
+
attribute :address, Types::Address
|
8
|
+
attribute :slug, Types::String
|
9
|
+
attribute :description, Types::String
|
10
|
+
attribute :type, Types::ShipperAccountTypes
|
11
|
+
attribute :timezone, Types::Timezone
|
12
|
+
attribute :created_at, Types::DateTime
|
13
|
+
attribute :updated_at, Types::DateTime
|
14
|
+
|
15
|
+
# Returns all ShipperAccounts
|
16
|
+
#
|
17
|
+
# @see ShipperAccountCollection#all
|
18
|
+
# @return [ShipperAccountCollection] Collection of ShipperAccounts
|
19
|
+
def self.all(options = {})
|
20
|
+
ShipperAccountCollection.all(options)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Fetches single ShipperAccount
|
24
|
+
#
|
25
|
+
# @see ShipperAccountCollection#find
|
26
|
+
# @return [ShipperAccount]
|
27
|
+
def self.find(id)
|
28
|
+
ShipperAccountCollection.find(id)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Creates an instance of ShipperAccount
|
32
|
+
#
|
33
|
+
# @see ShipperAccountCollection#create
|
34
|
+
# @return [ShipperAccount]
|
35
|
+
def self.create(params)
|
36
|
+
ShipperAccountCollection.create(params)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Deletes given ShipperAccount
|
40
|
+
#
|
41
|
+
# @see https://docs.postmen.com/api.html#shipper-accounts-delete-a-shipper-account API Documentation
|
42
|
+
def destroy
|
43
|
+
Connection.new.delete("/shipper-accounts/#{@id}")
|
44
|
+
end
|
45
|
+
|
46
|
+
# Update a ShipperAccount credentials
|
47
|
+
#
|
48
|
+
# @see https://docs.postmen.com/api.html#shipper-accounts-update-a-shipper-account-credentials
|
49
|
+
# @return [ShipperAccount] Updated ShipperAccount resource
|
50
|
+
def update_credentials(params = {})
|
51
|
+
Connection.new.put(
|
52
|
+
"/shipper-accounts/#{@id}/credentials",
|
53
|
+
ShipperAccountUpdateCredentialsQuery.new(params).to_hash
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Update a shipper account information
|
58
|
+
#
|
59
|
+
# @see https://docs.postmen.com/api.html#shipper-accounts-update-a-shipper-account-information API Documentation
|
60
|
+
# @example
|
61
|
+
# .update(description: "Your new description")
|
62
|
+
# .update(address: {})
|
63
|
+
# @return [ShipperAccount] Updated ShipperAccount resource
|
64
|
+
def update(params = {})
|
65
|
+
Connection.new.put("/shipper-accounts/#{@id}/info", ShipperAccountUpdateQuery.new(params.merge(subject: self)).to_query)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class Postmen
|
2
|
+
# This class wraps the array of ShipperAccount models
|
3
|
+
class ShipperAccountCollection
|
4
|
+
include CollectionProxy
|
5
|
+
|
6
|
+
model ShipperAccount
|
7
|
+
key :shipper_accounts
|
8
|
+
|
9
|
+
# Fetch all shipper accounts.
|
10
|
+
#
|
11
|
+
# @param options [Hash] Options for the query.
|
12
|
+
# @see https://docs.postmen.com/api.html#shipper-accounts-list-all-shipper-accounts API documentation
|
13
|
+
# @example
|
14
|
+
# .all # Returns all shipper accounts, default query.
|
15
|
+
# .all(slug: :aramex) # Returns only Shipper accounts from Aramex
|
16
|
+
def self.all(options = {})
|
17
|
+
new(Connection.new.get('/shipper-accounts', ShipperAccountQuery.new(options).to_query).parsed_response)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Fetch single ShipperAccount
|
21
|
+
#
|
22
|
+
# @param id [UUID] ShipperAccount UUID
|
23
|
+
# @see https://docs.postmen.com/api.html#shipper-accounts-retrieve-a-shipper-account API documentation
|
24
|
+
# @return [ShipperAccount]
|
25
|
+
# @raise ResourceNotFound if ShipperAccount with given id was not found
|
26
|
+
def self.find(id)
|
27
|
+
get(Connection.new.get("/shipper-accounts/#{id}").parsed_response)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Creates a ShipperAccount
|
31
|
+
#
|
32
|
+
# @param params [Hash] ShipperAccount params
|
33
|
+
# @see https://docs.postmen.com/api.html#shipper-accounts-create-a-shipper-account API documentation
|
34
|
+
# @return [ShipperAccount]
|
35
|
+
def self.create(params)
|
36
|
+
ShipperAccount.new(Connection.new.post('/shipper-accounts', CreateShipperAccountQuery.new(params).to_query).parsed_response[:data])
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class Postmen
|
2
|
+
module Types
|
3
|
+
# Address object
|
4
|
+
#
|
5
|
+
# @see https://docs.postmen.com/api.html#address API Documentation
|
6
|
+
class Address < Dry::Struct
|
7
|
+
constructor_type :strict_with_defaults
|
8
|
+
|
9
|
+
attribute :country, Types::Country
|
10
|
+
attribute :contact_name, Types::String.optional.default(nil)
|
11
|
+
attribute :phone, Types::String.optional.default(nil)
|
12
|
+
attribute :fax, Types::String.optional.default(nil)
|
13
|
+
attribute :email, Types::String.optional.default(nil)
|
14
|
+
attribute :company_name, Types::String.optional.default(nil)
|
15
|
+
attribute :street1, Types::String.optional.default(nil)
|
16
|
+
attribute :street2, Types::String.optional.default(nil)
|
17
|
+
attribute :street3, Types::String.optional.default(nil)
|
18
|
+
attribute :city, Types::String.optional.default(nil)
|
19
|
+
attribute :state, Types::String.optional.default(nil)
|
20
|
+
attribute :postal_code, Types::String.optional.default(nil)
|
21
|
+
attribute :type, Types::AddressType.optional.default(nil)
|
22
|
+
attribute :tax_id, Types::String.optional.default(nil)
|
23
|
+
|
24
|
+
# Converts object to hash
|
25
|
+
# @return [Hash]
|
26
|
+
def to_hash
|
27
|
+
super.reject { |_k, v| v.nil? }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class Postmen
|
2
|
+
module Types
|
3
|
+
# EEI type - AES - used in Customs object
|
4
|
+
# @see Customs
|
5
|
+
# @see https://docs.postmen.com/api.html#aes API Documentation
|
6
|
+
class AES < Dry::Struct
|
7
|
+
attribute :type, Types::String
|
8
|
+
attribute :itn_number, Types::String
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class Postmen
|
2
|
+
module Types
|
3
|
+
# Shipper account object
|
4
|
+
# (brief information for rate and manifest responses)
|
5
|
+
# @see https://docs.postmen.com/api.html#shipper-account-information API Documentation
|
6
|
+
class BriefShipperAccount < Dry::Struct
|
7
|
+
attribute :id, Types::UUID
|
8
|
+
attribute :slug, Types::String
|
9
|
+
attribute :description, Types::String
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Postmen
|
2
|
+
module Types
|
3
|
+
# Customs object
|
4
|
+
# @see https://docs.postmen.com/api.html#customs API Documentation
|
5
|
+
class Customs < Dry::Struct
|
6
|
+
constructor_type :schema
|
7
|
+
|
8
|
+
attribute :purpose, Types::CustomsPurpose
|
9
|
+
attribute :terms_of_trade, Types::TermsOfTrade
|
10
|
+
attribute :eei, Types::AES | Types::NoEEI
|
11
|
+
attribute :billing, Types::CustomsBilling
|
12
|
+
attribute :importer_address, Address
|
13
|
+
attribute :passport, Passport
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Postmen
|
2
|
+
module Types
|
3
|
+
# Customs billing
|
4
|
+
#
|
5
|
+
# @see https://docs.postmen.com/api.html#customs-billing API Documentation
|
6
|
+
class CustomsBilling < Dry::Struct
|
7
|
+
constructor_type :schema
|
8
|
+
|
9
|
+
attribute :paid_by, Types::PaidBy
|
10
|
+
attribute :method, Types::PaymentMethod
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class Postmen
|
2
|
+
module Types
|
3
|
+
# Dimension
|
4
|
+
# @see https://docs.postmen.com/api.html#dimension API Documentation
|
5
|
+
class Dimension < Dry::Struct
|
6
|
+
attribute :width, Types::Float
|
7
|
+
attribute :height, Types::Float
|
8
|
+
attribute :depth, Types::Float
|
9
|
+
attribute :unit, Types::DimensionUnit
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Postmen
|
2
|
+
module Types
|
3
|
+
# Item - element of shippment
|
4
|
+
# @see https://docs.postmen.com/api.html#item API Documentation
|
5
|
+
class Item < Dry::Struct
|
6
|
+
constructor_type :schema
|
7
|
+
|
8
|
+
attribute :description, Types::String
|
9
|
+
attribute :quantity, Types::Int
|
10
|
+
attribute :price, Types::Money
|
11
|
+
attribute :weight, Types::Weight
|
12
|
+
attribute :item_id, Types::String
|
13
|
+
attribute :origin_country, Types::Country
|
14
|
+
attribute :sku, Types::String
|
15
|
+
attribute :hs_code, Types::String
|
16
|
+
|
17
|
+
# Converts object to hash
|
18
|
+
# @return [Hash]
|
19
|
+
def to_hash
|
20
|
+
super.reject { |_k, v| v.nil? }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class Postmen
|
2
|
+
module Types
|
3
|
+
# EEI type - no_eei - used in Customs object
|
4
|
+
# @see Customs
|
5
|
+
# @see https://docs.postmen.com/api.html#no_eei API Documentation
|
6
|
+
class NoEEI < Dry::Struct
|
7
|
+
attribute :type, Types::String
|
8
|
+
attribute :ftr_exemption, Types::FtrExemption
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Postmen
|
2
|
+
module Types
|
3
|
+
# Passport object
|
4
|
+
#
|
5
|
+
# @see https://docs.postmen.com/api.html#passport API Documentation
|
6
|
+
class Passport < Dry::Struct
|
7
|
+
# Expected format for dates
|
8
|
+
# example value: 2017-01-19
|
9
|
+
DATE_FORMAT = '%F'.freeze
|
10
|
+
|
11
|
+
attribute :number, Types::String
|
12
|
+
attribute :issue_date, Types::Date
|
13
|
+
|
14
|
+
# Formats issue date to expected format
|
15
|
+
# @return [String]
|
16
|
+
def issue_date
|
17
|
+
super.strftime(DATE_FORMAT)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Postmen
|
2
|
+
module Types
|
3
|
+
# Payment method.
|
4
|
+
#
|
5
|
+
# @see https://docs.postmen.com/api.html#payment-method---account API Documentation
|
6
|
+
class PaymentMethod < Dry::Struct
|
7
|
+
attribute :type, Types::String
|
8
|
+
attribute :account_number, Types::String
|
9
|
+
attribute :postal_code, Types::String
|
10
|
+
attribute :country, Country
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class Postmen
|
2
|
+
module Types
|
3
|
+
# UUID Type
|
4
|
+
#
|
5
|
+
# @see https://en.wikipedia.org/wiki/Universally_unique_identifier Definition
|
6
|
+
UUID = Types::Strict::String.constrained(
|
7
|
+
format: /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
|
8
|
+
)
|
9
|
+
end
|
10
|
+
end
|
data/lib/postmen/types.rb
CHANGED
@@ -1,14 +1,20 @@
|
|
1
|
+
# Load '.maybe' extension for DRY::Types
|
1
2
|
Dry::Types.load_extensions(:maybe)
|
2
3
|
|
3
4
|
class Postmen
|
5
|
+
# This module holds all definitions of simple types used in the API
|
4
6
|
module Types
|
5
7
|
include Dry::Types.module
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
+
# Possible statuses for Rates.
|
10
|
+
RateStatuses = Types::String.enum(
|
11
|
+
'calculating',
|
12
|
+
'calculated',
|
13
|
+
'failed'
|
9
14
|
)
|
10
15
|
|
11
|
-
|
16
|
+
# Possible statuses for Labels.
|
17
|
+
LabelStatuses = Types::String.enum(
|
12
18
|
'creating',
|
13
19
|
'created',
|
14
20
|
'cancelling',
|
@@ -18,8 +24,33 @@ class Postmen
|
|
18
24
|
'failed'
|
19
25
|
)
|
20
26
|
|
21
|
-
|
22
|
-
|
27
|
+
# Possible statuses for Manifest
|
28
|
+
ManifestStatuses = Types::String.enum(
|
29
|
+
'manifesting',
|
30
|
+
'manifested',
|
31
|
+
'failed'
|
32
|
+
)
|
33
|
+
|
34
|
+
# Type of the address
|
35
|
+
# @see Address
|
36
|
+
AddressType = Types::String.enum(
|
37
|
+
'business',
|
38
|
+
'residential'
|
39
|
+
)
|
40
|
+
|
41
|
+
# List of possible Shipper Account Types
|
42
|
+
ShipperAccountTypes = Types::String.enum(
|
43
|
+
'user',
|
44
|
+
'user_prepaid'
|
45
|
+
)
|
46
|
+
|
47
|
+
# Timezone (use IANA name)
|
48
|
+
Timezone = Types::String
|
49
|
+
|
50
|
+
# Name of the country
|
51
|
+
Country = Types::String
|
52
|
+
|
53
|
+
# Paper size
|
23
54
|
PaperSize = Types::String.enum(
|
24
55
|
'4x4',
|
25
56
|
'4x6',
|
@@ -30,8 +61,82 @@ class Postmen
|
|
30
61
|
'default'
|
31
62
|
)
|
32
63
|
|
33
|
-
|
34
|
-
|
35
|
-
|
64
|
+
# Purpose used in customs object
|
65
|
+
#
|
66
|
+
# @see https://docs.postmen.com/api.html#customs API Documentation
|
67
|
+
CustomsPurpose = Types::String.enum(
|
68
|
+
'gift',
|
69
|
+
'merchandise',
|
70
|
+
'sample',
|
71
|
+
'return',
|
72
|
+
'repair'
|
73
|
+
)
|
74
|
+
|
75
|
+
# Paid by, used in customs billing.
|
76
|
+
#
|
77
|
+
# @see CustomsBilling
|
78
|
+
# @see https://docs.postmen.com/api.html#customs-billing API Documentation
|
79
|
+
PaidBy = Types::String.enum(
|
80
|
+
'shipper',
|
81
|
+
'recipient',
|
82
|
+
'third_party'
|
83
|
+
)
|
84
|
+
|
85
|
+
# Terms of trade - used in customs object
|
86
|
+
#
|
87
|
+
# @see Customs
|
88
|
+
# @see https://docs.postmen.com/api.html#customs API Documentation
|
89
|
+
TermsOfTrade = Types::String.enum(
|
90
|
+
'dat',
|
91
|
+
'ddu',
|
92
|
+
'ddp',
|
93
|
+
'dap'
|
94
|
+
)
|
95
|
+
|
96
|
+
# FTR Exemption - used in NoEEI object
|
97
|
+
# @see NoEEI
|
98
|
+
# @see https://docs.postmen.com/api.html#no_eei API Documentation
|
99
|
+
FtrExemption = Types::String.enum(
|
100
|
+
'noeei_30_37_a',
|
101
|
+
'noeei_30_37_h',
|
102
|
+
'noeei_30_36'
|
103
|
+
)
|
104
|
+
|
105
|
+
# Unit of weight - used in Weight object
|
106
|
+
# @see Weight
|
107
|
+
WeightUnit = Types::String.enum(
|
108
|
+
'lb',
|
109
|
+
'kg',
|
110
|
+
'oz',
|
111
|
+
'g'
|
112
|
+
)
|
113
|
+
|
114
|
+
# Unit for dimension - used in Dimension object
|
115
|
+
# @see Dimension
|
116
|
+
DimensionUnit = Types::String.enum(
|
117
|
+
'cm',
|
118
|
+
'in',
|
119
|
+
'mm',
|
120
|
+
'm',
|
121
|
+
'ft',
|
122
|
+
'yd'
|
123
|
+
)
|
36
124
|
end
|
37
125
|
end
|
126
|
+
require_relative 'types/address'
|
127
|
+
require_relative 'types/invoice'
|
128
|
+
require_relative 'types/weight'
|
129
|
+
require_relative 'types/passport'
|
130
|
+
require_relative 'types/uuid'
|
131
|
+
require_relative 'types/reference'
|
132
|
+
require_relative 'types/payment_method'
|
133
|
+
require_relative 'types/brief_shipper_account'
|
134
|
+
require_relative 'types/dimension'
|
135
|
+
require_relative 'types/billing'
|
136
|
+
require_relative 'types/money'
|
137
|
+
require_relative 'types/item'
|
138
|
+
require_relative 'types/customs_billing'
|
139
|
+
require_relative 'types/aes'
|
140
|
+
require_relative 'types/no_eei'
|
141
|
+
require_relative 'types/customs'
|
142
|
+
require_relative 'types/detailed_charges'
|
data/lib/postmen/version.rb
CHANGED