Class: Paid::Address

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line_1:, line_2: OMIT, city:, state:, zip_code:, country:, additional_properties: nil) ⇒ Paid::Address

Parameters:

  • line_1 (String)
  • line_2 (String) (defaults to: OMIT)
  • city (String)
  • state (String)
  • zip_code (String)
  • country (String)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/paid_ruby/types/address.rb', line 35

def initialize(line_1:, line_2: OMIT, city:, state:, zip_code:, country:, additional_properties: nil)
  @line_1 = line_1
  @line_2 = line_2 if line_2 != OMIT
  @city = city
  @state = state
  @zip_code = zip_code
  @country = country
  @additional_properties = additional_properties
  @_field_set = { "line1": line_1, "line2": line_2, "city": city, "state": state, "zipCode": zip_code, "country": country }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



20
21
22
# File 'lib/paid_ruby/types/address.rb', line 20

def additional_properties
  @additional_properties
end

#cityString (readonly)

Returns:

  • (String)


12
13
14
# File 'lib/paid_ruby/types/address.rb', line 12

def city
  @city
end

#countryString (readonly)

Returns:

  • (String)


18
19
20
# File 'lib/paid_ruby/types/address.rb', line 18

def country
  @country
end

#line_1String (readonly)

Returns:

  • (String)


8
9
10
# File 'lib/paid_ruby/types/address.rb', line 8

def line_1
  @line_1
end

#line_2String (readonly)

Returns:

  • (String)


10
11
12
# File 'lib/paid_ruby/types/address.rb', line 10

def line_2
  @line_2
end

#stateString (readonly)

Returns:

  • (String)


14
15
16
# File 'lib/paid_ruby/types/address.rb', line 14

def state
  @state
end

#zip_codeString (readonly)

Returns:

  • (String)


16
17
18
# File 'lib/paid_ruby/types/address.rb', line 16

def zip_code
  @zip_code
end

Class Method Details

.from_json(json_object:) ⇒ Paid::Address

Parameters:

  • json_object (String)

Returns:



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/paid_ruby/types/address.rb', line 51

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  line_1 = parsed_json["line1"]
  line_2 = parsed_json["line2"]
  city = parsed_json["city"]
  state = parsed_json["state"]
  zip_code = parsed_json["zipCode"]
  country = parsed_json["country"]
  new(
    line_1: line_1,
    line_2: line_2,
    city: city,
    state: state,
    zip_code: zip_code,
    country: country,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


82
83
84
85
86
87
88
89
# File 'lib/paid_ruby/types/address.rb', line 82

def self.validate_raw(obj:)
  obj.line_1.is_a?(String) != false || raise("Passed value for field obj.line_1 is not the expected type, validation failed.")
  obj.line_2&.is_a?(String) != false || raise("Passed value for field obj.line_2 is not the expected type, validation failed.")
  obj.city.is_a?(String) != false || raise("Passed value for field obj.city is not the expected type, validation failed.")
  obj.state.is_a?(String) != false || raise("Passed value for field obj.state is not the expected type, validation failed.")
  obj.zip_code.is_a?(String) != false || raise("Passed value for field obj.zip_code is not the expected type, validation failed.")
  obj.country.is_a?(String) != false || raise("Passed value for field obj.country is not the expected type, validation failed.")
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


73
74
75
# File 'lib/paid_ruby/types/address.rb', line 73

def to_json
  @_field_set&.to_json
end