Class: CDEKApiClient::Entities::Service
- Inherits:
-
Object
- Object
- CDEKApiClient::Entities::Service
- Includes:
- Validatable
- Defined in:
- lib/cdek_api_client/entities/service.rb
Overview
Represents a service entity in the CDEK API. Each service includes attributes such as code, price, and name.
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#name ⇒ Object
Returns the value of attribute name.
-
#price ⇒ Object
Returns the value of attribute price.
Instance Method Summary collapse
-
#initialize(code:, price:, name:) ⇒ Service
constructor
Initializes a new Service object.
-
#to_json(*_args) ⇒ String
Converts the Service object to a JSON representation.
Methods included from Validatable
Constructor Details
#initialize(code:, price:, name:) ⇒ Service
Initializes a new Service object.
25 26 27 28 29 30 |
# File 'lib/cdek_api_client/entities/service.rb', line 25 def initialize(code:, price:, name:) @code = code @price = price @name = name validate! end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
13 14 15 |
# File 'lib/cdek_api_client/entities/service.rb', line 13 def code @code end |
#name ⇒ Object
Returns the value of attribute name.
13 14 15 |
# File 'lib/cdek_api_client/entities/service.rb', line 13 def name @name end |
#price ⇒ Object
Returns the value of attribute price.
13 14 15 |
# File 'lib/cdek_api_client/entities/service.rb', line 13 def price @price end |
Instance Method Details
#to_json(*_args) ⇒ String
Converts the Service object to a JSON representation.
35 36 37 38 39 40 41 |
# File 'lib/cdek_api_client/entities/service.rb', line 35 def to_json(*_args) { code: @code, price: @price, name: @name }.to_json end |