Class: Recras::ContactForm

Inherits:
Object
  • Object
show all
Extended by:
Recras
Defined in:
lib/recras/contact_form.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) ⇒ ContactForm

Initializer to transform a Hash into an Client object

Parameters:

  • args (Hash) (defaults to: nil)


16
17
18
19
20
21
22
# File 'lib/recras/contact_form.rb', line 16

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.



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

def client
  @client
end

#idObject

Note:

The is a required parameter.



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

def id
  @id
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

Class Method Details

.attribute_mappingObject

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



51
52
53
# File 'lib/recras/contact_form.rb', line 51

def self.attribute_mapping
  [["id", "id"],["name", "name"]]
end

.plural_nameObject



24
25
26
# File 'lib/recras/contact_form.rb', line 24

def self.plural_name
  "contact_forms"
end

Instance Method Details

#contact_form_fieldsObject

returns an array of Recras::ContactFormField elements



29
30
31
32
33
34
35
36
# File 'lib/recras/contact_form.rb', line 29

def contact_form_fields
  json = client.make_request("contactformulieren/#{id}/velden")
  a = []
  for element in json
    a << Recras.parse_json(json: element, endpoint: "velden", client: client)
  end
  return a
end

#default_valuesObject

returns the minimum required attributes to make a valid booking. Only use this for testing purpose.



40
41
42
43
44
45
46
# File 'lib/recras/contact_form.rb', line 40

def default_values
  a = {}
  for field in contact_form_fields
    a[field.field_identifier] = field.default_value
  end
  return a
end