Class: CDEKApiClient::Entities::IntakeAvailableDaysResponse

Inherits:
Object
  • Object
show all
Includes:
Validatable
Defined in:
lib/cdek_api_client/entities/intake_available_days_response.rb

Overview

Represents a response with available courier intake days from the CDEK API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validatable

included, #validate!

Constructor Details

#initialize(date: nil, all_days: nil, errors: nil, warnings: nil) ⇒ IntakeAvailableDaysResponse

Initializes a new IntakeAvailableDaysResponse object.

Parameters:

  • date (Array<String>, nil) (defaults to: nil)

    the available dates for intake.

  • all_days (Boolean, nil) (defaults to: nil)

    whether all days are available.

  • errors (Array, nil) (defaults to: nil)

    any errors in the response.

  • warnings (Array, nil) (defaults to: nil)

    any warnings in the response.

Raises:

  • (ArgumentError)

    if any attribute validation fails.



25
26
27
28
29
30
31
# File 'lib/cdek_api_client/entities/intake_available_days_response.rb', line 25

def initialize(date: nil, all_days: nil, errors: nil, warnings: nil)
  @date = date
  @all_days = all_days
  @errors = errors || []
  @warnings = warnings || []
  validate!
end

Instance Attribute Details

#all_daysObject

Returns the value of attribute all_days.



11
12
13
# File 'lib/cdek_api_client/entities/intake_available_days_response.rb', line 11

def all_days
  @all_days
end

#dateObject

Returns the value of attribute date.



11
12
13
# File 'lib/cdek_api_client/entities/intake_available_days_response.rb', line 11

def date
  @date
end

#errorsObject

Returns the value of attribute errors.



11
12
13
# File 'lib/cdek_api_client/entities/intake_available_days_response.rb', line 11

def errors
  @errors
end

#warningsObject

Returns the value of attribute warnings.



11
12
13
# File 'lib/cdek_api_client/entities/intake_available_days_response.rb', line 11

def warnings
  @warnings
end

Instance Method Details

#to_json(*_args) ⇒ String

Converts the IntakeAvailableDaysResponse object to a JSON representation.

Returns:

  • (String)

    the JSON representation of the IntakeAvailableDaysResponse.



36
37
38
39
40
41
42
43
# File 'lib/cdek_api_client/entities/intake_available_days_response.rb', line 36

def to_json(*_args)
  data = {}
  data[:date] = @date if @date
  data[:all_days] = @all_days unless @all_days.nil?
  data[:errors] = @errors unless @errors.empty?
  data[:warnings] = @warnings unless @warnings.empty?
  data.to_json
end