Class: CyberSourceMergedSpec::Service

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/cyber_source_merged_spec/models/service.rb

Overview

Service 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(category_code: SKIP, sub_category_code: SKIP, fee_amount: SKIP, fee_code: SKIP, additional_properties: nil) ⇒ Service

Returns a new instance of Service.



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/cyber_source_merged_spec/models/service.rb', line 72

def initialize(category_code: SKIP, sub_category_code: SKIP,
               fee_amount: SKIP, fee_code: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @category_code = category_code unless category_code == SKIP
  @sub_category_code = sub_category_code unless sub_category_code == SKIP
  @fee_amount = fee_amount unless fee_amount == SKIP
  @fee_code = fee_code unless fee_code == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#category_codeString

Category code for the ancillary service that is provided. Obtain the codes from the International Air Transport Association (IATA). Note # is either 0, 1, 2, or 3. Important This field is required in the U.S. in order for you to qualify for either the custom payment service (CPS) or the electronic interchange reimbursement fee (EIRF)program. Format: English characters only. Optional request field for ancillary services.

Returns:

  • (String)


23
24
25
# File 'lib/cyber_source_merged_spec/models/service.rb', line 23

def category_code
  @category_code
end

#fee_amountString

This field contains the fee amount. This value cannot be negative. You can include a decimal point (.), but no other special characters. Format: String, 15 characters maximum. Optional field for ancillary services.

Returns:

  • (String)


39
40
41
# File 'lib/cyber_source_merged_spec/models/service.rb', line 39

def fee_amount
  @fee_amount
end

#fee_codeString

This field contains the ancillary fee code. Format: Alphanumeric, 4 characters maximum. Optional field for ancillary services.

Returns:

  • (String)


45
46
47
# File 'lib/cyber_source_merged_spec/models/service.rb', line 45

def fee_code
  @fee_code
end

#sub_category_codeString

Subcategory code for the ancillary service category. Obtain the codes from the International Air Transport Association (IATA). Note # is either 0, 1, 2, or 3. Format English characters only. Optional request field for ancillary services.

Returns:

  • (String)


32
33
34
# File 'lib/cyber_source_merged_spec/models/service.rb', line 32

def sub_category_code
  @sub_category_code
end

Class Method Details

.from_element(root) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/cyber_source_merged_spec/models/service.rb', line 110

def self.from_element(root)
  category_code = XmlUtilities.from_element(root, 'categoryCode', String)
  sub_category_code = XmlUtilities.from_element(root, 'subCategoryCode',
                                                String)
  fee_amount = XmlUtilities.from_element(root, 'feeAmount', String)
  fee_code = XmlUtilities.from_element(root, 'feeCode', String)

  new(category_code: category_code,
      sub_category_code: sub_category_code,
      fee_amount: fee_amount,
      fee_code: fee_code,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/cyber_source_merged_spec/models/service.rb', line 85

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  category_code = hash.key?('categoryCode') ? hash['categoryCode'] : SKIP
  sub_category_code =
    hash.key?('subCategoryCode') ? hash['subCategoryCode'] : SKIP
  fee_amount = hash.key?('feeAmount') ? hash['feeAmount'] : SKIP
  fee_code = hash.key?('feeCode') ? hash['feeCode'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  Service.new(category_code: category_code,
              sub_category_code: sub_category_code,
              fee_amount: fee_amount,
              fee_code: fee_code,
              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



48
49
50
51
52
53
54
55
# File 'lib/cyber_source_merged_spec/models/service.rb', line 48

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['category_code'] = 'categoryCode'
  @_hash['sub_category_code'] = 'subCategoryCode'
  @_hash['fee_amount'] = 'feeAmount'
  @_hash['fee_code'] = 'feeCode'
  @_hash
end

.nullablesObject

An array for nullable fields



68
69
70
# File 'lib/cyber_source_merged_spec/models/service.rb', line 68

def self.nullables
  []
end

.optionalsObject

An array for optional fields



58
59
60
61
62
63
64
65
# File 'lib/cyber_source_merged_spec/models/service.rb', line 58

def self.optionals
  %w[
    category_code
    sub_category_code
    fee_amount
    fee_code
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



147
148
149
150
151
152
# File 'lib/cyber_source_merged_spec/models/service.rb', line 147

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} category_code: #{@category_code.inspect}, sub_category_code:"\
  " #{@sub_category_code.inspect}, fee_amount: #{@fee_amount.inspect}, fee_code:"\
  " #{@fee_code.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



139
140
141
142
143
144
# File 'lib/cyber_source_merged_spec/models/service.rb', line 139

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} category_code: #{@category_code}, sub_category_code: #{@sub_category_code},"\
  " fee_amount: #{@fee_amount}, fee_code: #{@fee_code}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/cyber_source_merged_spec/models/service.rb', line 124

def to_xml_element(doc, root_name)
  root = doc.create_element(root_name)

  XmlUtilities.add_as_subelement(doc, root, 'categoryCode', category_code)
  XmlUtilities.add_as_subelement(doc, root, 'subCategoryCode',
                                 sub_category_code)
  XmlUtilities.add_as_subelement(doc, root, 'feeAmount', fee_amount)
  XmlUtilities.add_as_subelement(doc, root, 'feeCode', fee_code)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end