Class: Paid::Agent

Inherits:
Object
  • Object
show all
Defined in:
lib/paid_ruby/types/agent.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, external_id: OMIT, organization_id:, name:, description: OMIT, active:, agent_code: OMIT, agent_attributes: OMIT, additional_properties: nil) ⇒ Paid::Agent

Parameters:

  • id (String)
  • external_id (String) (defaults to: OMIT)
  • organization_id (String)
  • name (String)
  • description (String) (defaults to: OMIT)
  • active (Boolean)
  • agent_code (String) (defaults to: OMIT)
  • agent_attributes (Array<Paid::AgentAttribute>) (defaults to: OMIT)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/paid_ruby/types/agent.rb', line 42

def initialize(id:, external_id: OMIT, organization_id:, name:, description: OMIT, active:, agent_code: OMIT, agent_attributes: OMIT, additional_properties: nil)
  @id = id
  @external_id = external_id if external_id != OMIT
  @organization_id = organization_id
  @name = name
  @description = description if description != OMIT
  @active = active
  @agent_code = agent_code if agent_code != OMIT
  @agent_attributes = agent_attributes if agent_attributes != OMIT
  @additional_properties = additional_properties
  @_field_set = { "id": id, "externalId": external_id, "organizationId": organization_id, "name": name, "description": description, "active": active, "agentCode": agent_code, "agentAttributes": agent_attributes }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#activeBoolean (readonly)

Returns:

  • (Boolean)


19
20
21
# File 'lib/paid_ruby/types/agent.rb', line 19

def active
  @active
end

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



25
26
27
# File 'lib/paid_ruby/types/agent.rb', line 25

def additional_properties
  @additional_properties
end

#agent_attributesArray<Paid::AgentAttribute> (readonly)

Returns:



23
24
25
# File 'lib/paid_ruby/types/agent.rb', line 23

def agent_attributes
  @agent_attributes
end

#agent_codeString (readonly)

Returns:

  • (String)


21
22
23
# File 'lib/paid_ruby/types/agent.rb', line 21

def agent_code
  @agent_code
end

#descriptionString (readonly)

Returns:

  • (String)


17
18
19
# File 'lib/paid_ruby/types/agent.rb', line 17

def description
  @description
end

#external_idString (readonly)

Returns:

  • (String)


11
12
13
# File 'lib/paid_ruby/types/agent.rb', line 11

def external_id
  @external_id
end

#idString (readonly)

Returns:

  • (String)


9
10
11
# File 'lib/paid_ruby/types/agent.rb', line 9

def id
  @id
end

#nameString (readonly)

Returns:

  • (String)


15
16
17
# File 'lib/paid_ruby/types/agent.rb', line 15

def name
  @name
end

#organization_idString (readonly)

Returns:

  • (String)


13
14
15
# File 'lib/paid_ruby/types/agent.rb', line 13

def organization_id
  @organization_id
end

Class Method Details

.from_json(json_object:) ⇒ Paid::Agent

Parameters:

  • json_object (String)

Returns:



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/paid_ruby/types/agent.rb', line 60

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = parsed_json["id"]
  external_id = parsed_json["externalId"]
  organization_id = parsed_json["organizationId"]
  name = parsed_json["name"]
  description = parsed_json["description"]
  active = parsed_json["active"]
  agent_code = parsed_json["agentCode"]
  agent_attributes = parsed_json["agentAttributes"]&.map do | item |
  item = item.to_json
  Paid::AgentAttribute.from_json(json_object: item)
end
  new(
    id: id,
    external_id: external_id,
    organization_id: organization_id,
    name: name,
    description: description,
    active: active,
    agent_code: agent_code,
    agent_attributes: agent_attributes,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


98
99
100
101
102
103
104
105
106
107
# File 'lib/paid_ruby/types/agent.rb', line 98

def self.validate_raw(obj:)
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.external_id&.is_a?(String) != false || raise("Passed value for field obj.external_id is not the expected type, validation failed.")
  obj.organization_id.is_a?(String) != false || raise("Passed value for field obj.organization_id is not the expected type, validation failed.")
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
  obj.active.is_a?(Boolean) != false || raise("Passed value for field obj.active is not the expected type, validation failed.")
  obj.agent_code&.is_a?(String) != false || raise("Passed value for field obj.agent_code is not the expected type, validation failed.")
  obj.agent_attributes&.is_a?(Array) != false || raise("Passed value for field obj.agent_attributes is not the expected type, validation failed.")
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


89
90
91
# File 'lib/paid_ruby/types/agent.rb', line 89

def to_json
  @_field_set&.to_json
end