Class: CDEKApiClient::Entities::Agreement
- Inherits:
-
Object
- Object
- CDEKApiClient::Entities::Agreement
- Includes:
- Validatable
- Defined in:
- lib/cdek_api_client/entities/agreement.rb
Overview
Represents an agreement entity for delivery agreements in the CDEK API.
Instance Attribute Summary collapse
-
#cdek_number ⇒ Object
Returns the value of attribute cdek_number.
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#date ⇒ Object
Returns the value of attribute date.
-
#delivery_point ⇒ Object
Returns the value of attribute delivery_point.
-
#time_from ⇒ Object
Returns the value of attribute time_from.
-
#time_to ⇒ Object
Returns the value of attribute time_to.
-
#to_location ⇒ Object
Returns the value of attribute to_location.
Instance Method Summary collapse
-
#initialize(cdek_number:, date:, time_from:, time_to:, comment: nil, delivery_point: nil, to_location: nil) ⇒ Agreement
constructor
Initializes a new Agreement object.
-
#to_json(*_args) ⇒ String
Converts the Agreement object to a JSON representation.
Methods included from Validatable
Constructor Details
#initialize(cdek_number:, date:, time_from:, time_to:, comment: nil, delivery_point: nil, to_location: nil) ⇒ Agreement
Initializes a new Agreement object.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cdek_api_client/entities/agreement.rb', line 31 def initialize(cdek_number:, date:, time_from:, time_to:, comment: nil, delivery_point: nil, to_location: nil) @cdek_number = cdek_number @date = date @time_from = time_from @time_to = time_to @comment = comment @delivery_point = delivery_point @to_location = to_location validate! end |
Instance Attribute Details
#cdek_number ⇒ Object
Returns the value of attribute cdek_number.
11 12 13 |
# File 'lib/cdek_api_client/entities/agreement.rb', line 11 def cdek_number @cdek_number end |
#comment ⇒ Object
Returns the value of attribute comment.
11 12 13 |
# File 'lib/cdek_api_client/entities/agreement.rb', line 11 def comment @comment end |
#date ⇒ Object
Returns the value of attribute date.
11 12 13 |
# File 'lib/cdek_api_client/entities/agreement.rb', line 11 def date @date end |
#delivery_point ⇒ Object
Returns the value of attribute delivery_point.
11 12 13 |
# File 'lib/cdek_api_client/entities/agreement.rb', line 11 def delivery_point @delivery_point end |
#time_from ⇒ Object
Returns the value of attribute time_from.
11 12 13 |
# File 'lib/cdek_api_client/entities/agreement.rb', line 11 def time_from @time_from end |
#time_to ⇒ Object
Returns the value of attribute time_to.
11 12 13 |
# File 'lib/cdek_api_client/entities/agreement.rb', line 11 def time_to @time_to end |
#to_location ⇒ Object
Returns the value of attribute to_location.
11 12 13 |
# File 'lib/cdek_api_client/entities/agreement.rb', line 11 def to_location @to_location end |
Instance Method Details
#to_json(*_args) ⇒ String
Converts the Agreement object to a JSON representation.
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cdek_api_client/entities/agreement.rb', line 45 def to_json(*_args) data = { cdek_number: @cdek_number, date: @date, time_from: @time_from, time_to: @time_to } data[:comment] = @comment if @comment data[:delivery_point] = @delivery_point if @delivery_point data[:to_location] = @to_location if @to_location data.to_json end |