Class: Gusto::Documents::DocumentFieldsItem

Inherits:
Object
  • Object
show all
Defined in:
lib/fern_gusto/documents/types/document_fields_item.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key: OMIT, value: OMIT, x: OMIT, y: OMIT, width: OMIT, height: OMIT, page_number: OMIT, data_type: OMIT, required: OMIT, additional_properties: nil) ⇒ Gusto::Documents::DocumentFieldsItem

Parameters:

  • key (String) (defaults to: OMIT)

    Unique identifier of the field

  • value (String) (defaults to: OMIT)

    Auto-filled value of the field

  • x (Integer) (defaults to: OMIT)

    X-coordinate location of the field on the page

  • y (Integer) (defaults to: OMIT)

    Y-coordinate location of the field on the page

  • width (Integer) (defaults to: OMIT)

    Width of the field

  • height (Integer) (defaults to: OMIT)

    Height of the field

  • page_number (Integer) (defaults to: OMIT)

    Page number of the field

  • data_type (String) (defaults to: OMIT)

    The field’s data type

  • required (Boolean) (defaults to: OMIT)

    Whether the field is required

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fern_gusto/documents/types/document_fields_item.rb', line 45

def initialize(key: OMIT, value: OMIT, x: OMIT, y: OMIT, width: OMIT, height: OMIT, page_number: OMIT, data_type: OMIT, required: OMIT, additional_properties: nil)
  @key = key if key != OMIT
  @value = value if value != OMIT
  @x = x if x != OMIT
  @y = y if y != OMIT
  @width = width if width != OMIT
  @height = height if height != OMIT
  @page_number = page_number if page_number != OMIT
  @data_type = data_type if data_type != OMIT
  @required = required if required != OMIT
  @additional_properties = additional_properties
  @_field_set = { "key": key, "value": value, "x": x, "y": y, "width": width, "height": height, "page_number": page_number, "data_type": data_type, "required": required }.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



27
28
29
# File 'lib/fern_gusto/documents/types/document_fields_item.rb', line 27

def additional_properties
  @additional_properties
end

#data_typeString (readonly)

Returns The field’s data type.

Returns:

  • (String)

    The field’s data type



23
24
25
# File 'lib/fern_gusto/documents/types/document_fields_item.rb', line 23

def data_type
  @data_type
end

#heightInteger (readonly)

Returns Height of the field.

Returns:

  • (Integer)

    Height of the field



19
20
21
# File 'lib/fern_gusto/documents/types/document_fields_item.rb', line 19

def height
  @height
end

#keyString (readonly)

Returns Unique identifier of the field.

Returns:

  • (String)

    Unique identifier of the field



9
10
11
# File 'lib/fern_gusto/documents/types/document_fields_item.rb', line 9

def key
  @key
end

#page_numberInteger (readonly)

Returns Page number of the field.

Returns:

  • (Integer)

    Page number of the field



21
22
23
# File 'lib/fern_gusto/documents/types/document_fields_item.rb', line 21

def page_number
  @page_number
end

#requiredBoolean (readonly)

Returns Whether the field is required.

Returns:

  • (Boolean)

    Whether the field is required



25
26
27
# File 'lib/fern_gusto/documents/types/document_fields_item.rb', line 25

def required
  @required
end

#valueString (readonly)

Returns Auto-filled value of the field.

Returns:

  • (String)

    Auto-filled value of the field



11
12
13
# File 'lib/fern_gusto/documents/types/document_fields_item.rb', line 11

def value
  @value
end

#widthInteger (readonly)

Returns Width of the field.

Returns:

  • (Integer)

    Width of the field



17
18
19
# File 'lib/fern_gusto/documents/types/document_fields_item.rb', line 17

def width
  @width
end

#xInteger (readonly)

Returns X-coordinate location of the field on the page.

Returns:

  • (Integer)

    X-coordinate location of the field on the page



13
14
15
# File 'lib/fern_gusto/documents/types/document_fields_item.rb', line 13

def x
  @x
end

#yInteger (readonly)

Returns Y-coordinate location of the field on the page.

Returns:

  • (Integer)

    Y-coordinate location of the field on the page



15
16
17
# File 'lib/fern_gusto/documents/types/document_fields_item.rb', line 15

def y
  @y
end

Class Method Details

.from_json(json_object:) ⇒ Gusto::Documents::DocumentFieldsItem

Parameters:

  • json_object (String)

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/fern_gusto/documents/types/document_fields_item.rb', line 64

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  key = parsed_json["key"]
  value = parsed_json["value"]
  x = parsed_json["x"]
  y = parsed_json["y"]
  width = parsed_json["width"]
  height = parsed_json["height"]
  page_number = parsed_json["page_number"]
  data_type = parsed_json["data_type"]
  required = parsed_json["required"]
  new(
    key: key,
    value: value,
    x: x,
    y: y,
    width: width,
    height: height,
    page_number: page_number,
    data_type: data_type,
    required: required,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


101
102
103
104
105
106
107
108
109
110
111
# File 'lib/fern_gusto/documents/types/document_fields_item.rb', line 101

def self.validate_raw(obj:)
  obj.key&.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
  obj.value&.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
  obj.x&.is_a?(Integer) != false || raise("Passed value for field obj.x is not the expected type, validation failed.")
  obj.y&.is_a?(Integer) != false || raise("Passed value for field obj.y is not the expected type, validation failed.")
  obj.width&.is_a?(Integer) != false || raise("Passed value for field obj.width is not the expected type, validation failed.")
  obj.height&.is_a?(Integer) != false || raise("Passed value for field obj.height is not the expected type, validation failed.")
  obj.page_number&.is_a?(Integer) != false || raise("Passed value for field obj.page_number is not the expected type, validation failed.")
  obj.data_type&.is_a?(String) != false || raise("Passed value for field obj.data_type is not the expected type, validation failed.")
  obj.required&.is_a?(Boolean) != false || raise("Passed value for field obj.required is not the expected type, validation failed.")
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


92
93
94
# File 'lib/fern_gusto/documents/types/document_fields_item.rb', line 92

def to_json
  @_field_set&.to_json
end