Class: CDEKApiClient::Entities::Item
- Inherits:
-
Object
- Object
- CDEKApiClient::Entities::Item
- Includes:
- Validatable
- Defined in:
- lib/cdek_api_client/entities/item.rb
Overview
Represents an item in the CDEK API. Each item has attributes such as ware key, payment, name, cost, amount, weight, and optional URL.
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#cost ⇒ Object
Returns the value of attribute cost.
-
#name ⇒ Object
Returns the value of attribute name.
-
#payment ⇒ Object
Returns the value of attribute payment.
-
#url ⇒ Object
Returns the value of attribute url.
-
#ware_key ⇒ Object
Returns the value of attribute ware_key.
-
#weight ⇒ Object
Returns the value of attribute weight.
Instance Method Summary collapse
-
#initialize(ware_key:, payment:, name:, cost:, amount:, weight:, url: nil) ⇒ Item
constructor
Initializes a new Item object.
-
#to_json(*_args) ⇒ String
Converts the Item object to a JSON representation.
Methods included from Validatable
Constructor Details
#initialize(ware_key:, payment:, name:, cost:, amount:, weight:, url: nil) ⇒ Item
Initializes a new Item object.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cdek_api_client/entities/item.rb', line 32 def initialize(ware_key:, payment:, name:, cost:, amount:, weight:, url: nil) @ware_key = ware_key @payment = payment @name = name @cost = cost @amount = amount @weight = weight @url = url validate! end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
13 14 15 |
# File 'lib/cdek_api_client/entities/item.rb', line 13 def amount @amount end |
#cost ⇒ Object
Returns the value of attribute cost.
13 14 15 |
# File 'lib/cdek_api_client/entities/item.rb', line 13 def cost @cost end |
#name ⇒ Object
Returns the value of attribute name.
13 14 15 |
# File 'lib/cdek_api_client/entities/item.rb', line 13 def name @name end |
#payment ⇒ Object
Returns the value of attribute payment.
13 14 15 |
# File 'lib/cdek_api_client/entities/item.rb', line 13 def payment @payment end |
#url ⇒ Object
Returns the value of attribute url.
13 14 15 |
# File 'lib/cdek_api_client/entities/item.rb', line 13 def url @url end |
#ware_key ⇒ Object
Returns the value of attribute ware_key.
13 14 15 |
# File 'lib/cdek_api_client/entities/item.rb', line 13 def ware_key @ware_key end |
#weight ⇒ Object
Returns the value of attribute weight.
13 14 15 |
# File 'lib/cdek_api_client/entities/item.rb', line 13 def weight @weight end |
Instance Method Details
#to_json(*_args) ⇒ String
Converts the Item object to a JSON representation.
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cdek_api_client/entities/item.rb', line 46 def to_json(*_args) { ware_key: @ware_key, payment: @payment, name: @name, cost: @cost, amount: @amount, weight: @weight, url: @url }.to_json end |