Class: CDEKApiClient::Entities::TariffData
- Inherits:
-
Object
- Object
- CDEKApiClient::Entities::TariffData
- Includes:
- Validatable
- Defined in:
- lib/cdek_api_client/entities/tariff_data.rb
Overview
Represents the data required to calculate a tariff in the CDEK API. Each tariff data includes attributes such as type, currency, from_location, to_location, packages, and tariff_code.
Instance Attribute Summary collapse
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#from_location ⇒ Object
Returns the value of attribute from_location.
-
#packages ⇒ Object
Returns the value of attribute packages.
-
#tariff_code ⇒ Object
Returns the value of attribute tariff_code.
-
#to_location ⇒ Object
Returns the value of attribute to_location.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type:, currency:, from_location:, to_location:, packages:, tariff_code:) ⇒ TariffData
constructor
Initializes a new TariffData object.
-
#to_json(*_args) ⇒ String
Converts the TariffData object to a JSON representation.
Methods included from Validatable
Constructor Details
#initialize(type:, currency:, from_location:, to_location:, packages:, tariff_code:) ⇒ TariffData
Initializes a new TariffData object.
32 33 34 35 36 37 38 39 40 |
# File 'lib/cdek_api_client/entities/tariff_data.rb', line 32 def initialize(type:, currency:, from_location:, to_location:, packages:, tariff_code:) @type = type @currency = CurrencyMapper.to_code(currency) @from_location = from_location @to_location = to_location @packages = packages @tariff_code = tariff_code validate! end |
Instance Attribute Details
#currency ⇒ Object
Returns the value of attribute currency.
14 15 16 |
# File 'lib/cdek_api_client/entities/tariff_data.rb', line 14 def currency @currency end |
#from_location ⇒ Object
Returns the value of attribute from_location.
14 15 16 |
# File 'lib/cdek_api_client/entities/tariff_data.rb', line 14 def from_location @from_location end |
#packages ⇒ Object
Returns the value of attribute packages.
14 15 16 |
# File 'lib/cdek_api_client/entities/tariff_data.rb', line 14 def packages @packages end |
#tariff_code ⇒ Object
Returns the value of attribute tariff_code.
14 15 16 |
# File 'lib/cdek_api_client/entities/tariff_data.rb', line 14 def tariff_code @tariff_code end |
#to_location ⇒ Object
Returns the value of attribute to_location.
14 15 16 |
# File 'lib/cdek_api_client/entities/tariff_data.rb', line 14 def to_location @to_location end |
#type ⇒ Object
Returns the value of attribute type.
14 15 16 |
# File 'lib/cdek_api_client/entities/tariff_data.rb', line 14 def type @type end |
Instance Method Details
#to_json(*_args) ⇒ String
Converts the TariffData object to a JSON representation.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/cdek_api_client/entities/tariff_data.rb', line 45 def to_json(*_args) { type: @type, currency: @currency, from_location: @from_location, to_location: @to_location, packages: @packages, tariff_code: @tariff_code }.to_json end |