Class: Recras::ContactFormField

Inherits:
Object
  • Object
show all
Extended by:
Recras
Defined in:
lib/recras/contact_form_field.rb

Overview

links to ‘arrangement_regels’ in the API recras.github.io/docs/endpoints/contactformulieren.html

Constant Summary

Constants included from Recras

API_VERSION, VERSION

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Recras

make_request, new_from_json, object_mappings, parse_json, url, version

Constructor Details

#initialize(args = nil) ⇒ ContactFormField

Initializer to transform a Hash into an Client object

Parameters:

  • args (Hash) (defaults to: nil)


23
24
25
26
27
28
29
# File 'lib/recras/contact_form_field.rb', line 23

def initialize(args=nil)
  required_args = []
  return if args.nil?
  args.each do |k,v|
    instance_variable_set("@#{k}", v) unless v.nil?
  end
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



18
19
20
# File 'lib/recras/contact_form_field.rb', line 18

def client
  @client
end

#contact_formObject

Returns the value of attribute contact_form.



17
18
19
# File 'lib/recras/contact_form_field.rb', line 17

def contact_form
  @contact_form
end

#contact_form_idObject

Returns the value of attribute contact_form_id.



11
12
13
# File 'lib/recras/contact_form_field.rb', line 11

def contact_form_id
  @contact_form_id
end

#field_identifierObject

Returns the value of attribute field_identifier.



16
17
18
# File 'lib/recras/contact_form_field.rb', line 16

def field_identifier
  @field_identifier
end

#idObject

Note:

The is a required parameter.



9
10
11
# File 'lib/recras/contact_form_field.rb', line 9

def id
  @id
end

#input_typeObject

Returns the value of attribute input_type.



12
13
14
# File 'lib/recras/contact_form_field.rb', line 12

def input_type
  @input_type
end

#jsonObject

Returns the value of attribute json.



19
20
21
# File 'lib/recras/contact_form_field.rb', line 19

def json
  @json
end

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/recras/contact_form_field.rb', line 10

def name
  @name
end

#optionsObject

Returns the value of attribute options.



14
15
16
# File 'lib/recras/contact_form_field.rb', line 14

def options
  @options
end

#requiredObject

Returns the value of attribute required.



13
14
15
# File 'lib/recras/contact_form_field.rb', line 13

def required
  @required
end

#special_for_bookingObject

Returns the value of attribute special_for_booking.



15
16
17
# File 'lib/recras/contact_form_field.rb', line 15

def special_for_booking
  @special_for_booking
end

Class Method Details

.attribute_mappingObject

translates the mapping between the Recras API and the terms used in this gem



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/recras/contact_form_field.rb', line 33

def self.attribute_mapping
  [
    ["id", "id"],
    ["naam", "name"],
    ["contactformulier_id", "contact_form_id"], 
    ["soort_invoer", "input_type"], 
    ["verplicht", "required"], 
    ["mogelijke_keuzes", "options"],
    ["bijzonderheden_boeking", "special_for_booking"],
    ["field_identifier", "field_identifier"]
  ]
end

Instance Method Details

#default_valueObject

returns default values for this field_identifier



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/recras/contact_form_field.rb', line 47

def default_value
  if field_identifier == "contactpersoon.email1"
    return "[email protected]"
  elsif field_identifier == "contactpersoon.naam"
    return "Naamloos"
  elsif field_identifier == "contactpersoon.voornaam"
    return "Voornaam"
  elsif field_identifier == "contactpersoon.achternaam"
    return "Achternaam"
  elsif field_identifier == "veel_tekst"
    return "tekst"
  else
    # raise ERRR
    return ""
  end
end