Class: ActiveCampaignWrapper::Core::GroupGateway

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ GroupGateway

Returns a new instance of GroupGateway.



6
7
8
9
# File 'lib/active_campaign_wrapper/core/group_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/group_gateway.rb', line 11

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

#create(params) ⇒ Object



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

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

#delete(group_id) ⇒ Object



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

def delete(group_id)
  @config.delete("/groups/#{group_id}")
end

#find(group_id) ⇒ Object



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

def find(group_id)
  @config.get("/groups/#{group_id}")
end

#update(group_id, params) ⇒ Object



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

def update(group_id, params)
  params = { group: params }
  @config.put(
    "/groups/#{group_id}",
    body: ActiveCampaignWrapper::Helpers.normalize_body(
      params,
      ActiveCampaignWrapper::Api::Group::Arguments::SNAKE_CASED[:create]
    )
  )
end