Class: NewStoreApi::CarriersConfigCarrier

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/carriers_config_carrier.rb

Overview

CarriersConfigCarrier Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(api_base_url = nil, api_key = SKIP, booking_includes_return = false, return_deliveries_should_be_canceled = false) ⇒ CarriersConfigCarrier

Returns a new instance of CarriersConfigCarrier.



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/new_store_api/models/carriers_config_carrier.rb', line 57

def initialize(api_base_url = nil, api_key = SKIP,
               booking_includes_return = false,
               return_deliveries_should_be_canceled = false)
  @api_base_url = api_base_url
  @api_key = api_key unless api_key == SKIP
  @booking_includes_return = booking_includes_return unless booking_includes_return == SKIP
  unless return_deliveries_should_be_canceled == SKIP
    @return_deliveries_should_be_canceled =
      return_deliveries_should_be_canceled
  end
end

Instance Attribute Details

#api_base_urlString

The shipping provider adapter URL. Must end with a slash /

Returns:

  • (String)


14
15
16
# File 'lib/new_store_api/models/carriers_config_carrier.rb', line 14

def api_base_url
  @api_base_url
end

#api_keyString

The shipping provider adapter URL. Must end with a slash /

Returns:

  • (String)


18
19
20
# File 'lib/new_store_api/models/carriers_config_carrier.rb', line 18

def api_key
  @api_key
end

#booking_includes_returnTrueClass | FalseClass

The shipping provider adapter URL. Must end with a slash /

Returns:

  • (TrueClass | FalseClass)


22
23
24
# File 'lib/new_store_api/models/carriers_config_carrier.rb', line 22

def booking_includes_return
  @booking_includes_return
end

#return_deliveries_should_be_canceledTrueClass | FalseClass

The shipping provider adapter URL. Must end with a slash /

Returns:

  • (TrueClass | FalseClass)


26
27
28
# File 'lib/new_store_api/models/carriers_config_carrier.rb', line 26

def return_deliveries_should_be_canceled
  @return_deliveries_should_be_canceled
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/new_store_api/models/carriers_config_carrier.rb', line 70

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  api_base_url = hash.key?('api_base_url') ? hash['api_base_url'] : nil
  api_key = hash.key?('api_key') ? hash['api_key'] : SKIP
  booking_includes_return = hash['booking_includes_return'] ||= false
  return_deliveries_should_be_canceled =
    hash['return_deliveries_should_be_canceled'] ||= false

  # Create object from extracted values.
  CarriersConfigCarrier.new(api_base_url,
                            api_key,
                            booking_includes_return,
                            return_deliveries_should_be_canceled)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
36
37
# File 'lib/new_store_api/models/carriers_config_carrier.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['api_base_url'] = 'api_base_url'
  @_hash['api_key'] = 'api_key'
  @_hash['booking_includes_return'] = 'booking_includes_return'
  @_hash['return_deliveries_should_be_canceled'] =
    'return_deliveries_should_be_canceled'
  @_hash
end

.nullablesObject

An array for nullable fields



49
50
51
52
53
54
55
# File 'lib/new_store_api/models/carriers_config_carrier.rb', line 49

def self.nullables
  %w[
    api_key
    booking_includes_return
    return_deliveries_should_be_canceled
  ]
end

.optionalsObject

An array for optional fields



40
41
42
43
44
45
46
# File 'lib/new_store_api/models/carriers_config_carrier.rb', line 40

def self.optionals
  %w[
    api_key
    booking_includes_return
    return_deliveries_should_be_canceled
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/new_store_api/models/carriers_config_carrier.rb', line 89

def self.validate(value)
  if value.instance_of? self
    return APIHelper.valid_type?(value.api_base_url,
                                 ->(val) { val.instance_of? String })
  end

  return false unless value.instance_of? Hash

  APIHelper.valid_type?(value['api_base_url'],
                        ->(val) { val.instance_of? String })
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



110
111
112
113
114
115
# File 'lib/new_store_api/models/carriers_config_carrier.rb', line 110

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} api_base_url: #{@api_base_url.inspect}, api_key: #{@api_key.inspect},"\
  " booking_includes_return: #{@booking_includes_return.inspect},"\
  " return_deliveries_should_be_canceled: #{@return_deliveries_should_be_canceled.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



102
103
104
105
106
107
# File 'lib/new_store_api/models/carriers_config_carrier.rb', line 102

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} api_base_url: #{@api_base_url}, api_key: #{@api_key},"\
  " booking_includes_return: #{@booking_includes_return},"\
  " return_deliveries_should_be_canceled: #{@return_deliveries_should_be_canceled}>"
end