Class: UriService::Client::FormFields

Inherits:
Object
  • Object
show all
Defined in:
lib/uri_service/client/form_fields.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ FormFields

Returns a new instance of FormFields.



6
7
8
# File 'lib/uri_service/client/form_fields.rb', line 6

def initialize(response)
  @specification = response.data
end

Instance Attribute Details

#specificationObject (readonly)

Returns the value of attribute specification.



4
5
6
# File 'lib/uri_service/client/form_fields.rb', line 4

def specification
  @specification
end

Instance Method Details

#custom_fields(action) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/uri_service/client/form_fields.rb', line 25

def custom_fields(action)
  case action.to_s
  when 'create'
    params_for('/vocabularies/{string_key}/custom_fields', 'post')
  when 'update'
    params_for(
      '/vocabularies/{string_key}/custom_fields/{field_key}',
      'patch'
    )
  when 'delete'
    params_for('/vocabularies/{string_key}/custom_fields/{field_key}',
               'delete')
  end
end

#term(vocabulary, action) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/uri_service/client/form_fields.rb', line 40

def term(vocabulary, action)
  case action.to_s
  when 'index'
    params_for("/vocabularies/#{vocabulary}/terms", 'get')
  when 'show'
    params_for("/vocabularies/#{vocabulary}/terms/{uri}", 'get')
  when 'create'
    params_for("/vocabularies/#{vocabulary}/terms", 'post')
  when 'update'
    params_for("/vocabularies/#{vocabulary}/terms/{uri}", 'patch')
  when 'delete'
    params_for("/vocabularies/#{vocabulary}/terms/{uri}", 'delete')
  end
end

#vocabulary(action) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/uri_service/client/form_fields.rb', line 10

def vocabulary(action)
  case action.to_s
  when 'index'
    params_for('/vocabularies', 'get')
  when 'show'
    params_for('/vocabularies/{string_key}', 'get')
  when 'create'
    params_for('/vocabularies', 'post')
  when 'update'
    params_for('/vocabularies/{string_key}', 'patch')
  when 'delete'
    params_for('/vocabularies/{string_key}', 'delete')
  end
end