Class: ActiveCampaignWrapper::Core::CustomFieldGateway

Inherits:
Object
  • Object
show all
Defined in:
lib/active_campaign_wrapper/core/custom_field_gateway.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ CustomFieldGateway

Returns a new instance of CustomFieldGateway.



6
7
8
9
# File 'lib/active_campaign_wrapper/core/custom_field_gateway.rb', line 6

def initialize(client)
  @client = client
  @config = client.config
end

Instance Method Details

#all(**params) ⇒ Object



11
12
13
# File 'lib/active_campaign_wrapper/core/custom_field_gateway.rb', line 11

def all(**params)
  @config.get('/fields', query: params)
end

#create(params) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/active_campaign_wrapper/core/custom_field_gateway.rb', line 15

def create(params)
  params = { field: params }
  @config.post(
    '/fields',
    body: ActiveCampaignWrapper::Helpers.normalize_body(
      params,
      ActiveCampaignWrapper::Api::CustomField::Arguments::SNAKE_CASED[:create]
    )
  )
end

#delete(field_id) ⇒ Object



26
27
28
# File 'lib/active_campaign_wrapper/core/custom_field_gateway.rb', line 26

def delete(field_id)
  @config.delete("/fields/#{field_id}")
end

#find(field_id) ⇒ Object



41
42
43
# File 'lib/active_campaign_wrapper/core/custom_field_gateway.rb', line 41

def find(field_id)
  @config.get("/fields/#{field_id}")
end


45
46
47
48
49
50
51
52
53
# File 'lib/active_campaign_wrapper/core/custom_field_gateway.rb', line 45

def link_to_list(field_id, list_id)
  params = { field_rel: { field: field_id, relid: list_id } }
  @config.post(
    '/fieldRels',
    body: ActiveCampaignWrapper::Helpers.normalize_body(
      params
    )
  )
end

#update(field_id, params) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/active_campaign_wrapper/core/custom_field_gateway.rb', line 30

def update(field_id, params)
  params = { field: params }
  @config.put(
    "/fields/#{field_id}",
    body: ActiveCampaignWrapper::Helpers.normalize_body(
      params,
      ActiveCampaignWrapper::Api::CustomField::Arguments::SNAKE_CASED[:create]
    )
  )
end