Class: CyberSourceMergedSpec::ReportFilters

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

Overview

ReportFilters 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(application_name: SKIP, first_name: SKIP, last_name: SKIP, email: SKIP, additional_properties: nil) ⇒ ReportFilters

Returns a new instance of ReportFilters.



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/cyber_source_merged_spec/models/report_filters.rb', line 53

def initialize(application_name: SKIP, first_name: SKIP, last_name: SKIP,
               email: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @application_name = application_name unless application_name == SKIP
  @first_name = first_name unless first_name == SKIP
  @last_name = last_name unless last_name == SKIP
  @email = email unless email == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#application_nameArray[String]

TODO: Write general description for this method

Returns:

  • (Array[String])


14
15
16
# File 'lib/cyber_source_merged_spec/models/report_filters.rb', line 14

def application_name
  @application_name
end

#emailArray[String]

TODO: Write general description for this method

Returns:

  • (Array[String])


26
27
28
# File 'lib/cyber_source_merged_spec/models/report_filters.rb', line 26

def email
  @email
end

#first_nameArray[String]

TODO: Write general description for this method

Returns:

  • (Array[String])


18
19
20
# File 'lib/cyber_source_merged_spec/models/report_filters.rb', line 18

def first_name
  @first_name
end

#last_nameArray[String]

TODO: Write general description for this method

Returns:

  • (Array[String])


22
23
24
# File 'lib/cyber_source_merged_spec/models/report_filters.rb', line 22

def last_name
  @last_name
end

Class Method Details

.from_element(root) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/cyber_source_merged_spec/models/report_filters.rb', line 91

def self.from_element(root)
  application_name = XmlUtilities.from_element_to_array(root,
                                                        'Application.Name',
                                                        String)
  first_name = XmlUtilities.from_element_to_array(root, 'firstName', String)
  last_name = XmlUtilities.from_element_to_array(root, 'lastName', String)
  email = XmlUtilities.from_element_to_array(root, 'email', String)

  new(application_name: application_name,
      first_name: first_name,
      last_name: last_name,
      email: email,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/cyber_source_merged_spec/models/report_filters.rb', line 66

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  application_name =
    hash.key?('Application.Name') ? hash['Application.Name'] : SKIP
  first_name = hash.key?('firstName') ? hash['firstName'] : SKIP
  last_name = hash.key?('lastName') ? hash['lastName'] : SKIP
  email = hash.key?('email') ? hash['email'] : 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.
  ReportFilters.new(application_name: application_name,
                    first_name: first_name,
                    last_name: last_name,
                    email: email,
                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
36
# File 'lib/cyber_source_merged_spec/models/report_filters.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['application_name'] = 'Application.Name'
  @_hash['first_name'] = 'firstName'
  @_hash['last_name'] = 'lastName'
  @_hash['email'] = 'email'
  @_hash
end

.nullablesObject

An array for nullable fields



49
50
51
# File 'lib/cyber_source_merged_spec/models/report_filters.rb', line 49

def self.nullables
  []
end

.optionalsObject

An array for optional fields



39
40
41
42
43
44
45
46
# File 'lib/cyber_source_merged_spec/models/report_filters.rb', line 39

def self.optionals
  %w[
    application_name
    first_name
    last_name
    email
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



129
130
131
132
133
134
# File 'lib/cyber_source_merged_spec/models/report_filters.rb', line 129

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} application_name: #{@application_name.inspect}, first_name:"\
  " #{@first_name.inspect}, last_name: #{@last_name.inspect}, email: #{@email.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



121
122
123
124
125
126
# File 'lib/cyber_source_merged_spec/models/report_filters.rb', line 121

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} application_name: #{@application_name}, first_name: #{@first_name},"\
  " last_name: #{@last_name}, email: #{@email}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/cyber_source_merged_spec/models/report_filters.rb', line 106

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

  XmlUtilities.add_array_as_subelement(doc, root, 'Application.Name',
                                       application_name)
  XmlUtilities.add_array_as_subelement(doc, root, 'firstName', first_name)
  XmlUtilities.add_array_as_subelement(doc, root, 'lastName', last_name)
  XmlUtilities.add_array_as_subelement(doc, root, 'email', email)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end