Class: UnbounceClient

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/unbounce_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ UnbounceClient



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

def initialize(api_key)
  @auth = { username: api_key, password: '' }
end

Instance Method Details

#accountsObject



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

def accounts
  parse( get('/accounts') )['accounts'].collect { || OpenStruct.new() }
end

#domains(id) ⇒ Object



31
32
33
# File 'lib/unbounce_client.rb', line 31

def domains(id)
  parse( get("/sub_accounts/#{id}/domains") )['domains'].collect { |domain| OpenStruct.new(domain) }
end

#lead(id) ⇒ Object



55
56
57
# File 'lib/unbounce_client.rb', line 55

def lead(id)
  OpenStruct.new( parse( get("/leads/#{id}") ) )
end

#leads(opts = { sub_account_id: nil, page_id: nil }) ⇒ Object



49
50
51
52
53
# File 'lib/unbounce_client.rb', line 49

def leads(opts={ sub_account_id: nil, page_id: nil })
  parent, id = opts_to_path_and_id(opts)

  parse( get("/#{parent}/#{id}/leads") )['leads'].collect { |lead| OpenStruct.new(lead) }
end

#page(id) ⇒ Object



45
46
47
# File 'lib/unbounce_client.rb', line 45

def page(id)
  OpenStruct.new( parse( get("/pages/#{id}") ) )
end

#page_groups(sub_account_id) ⇒ Object



35
36
37
# File 'lib/unbounce_client.rb', line 35

def page_groups()
  parse( get("/sub_accounts/#{sub_account_id}/page_groups") )['pageGroups'].collect { |page_group| OpenStruct.new(page_group) }
end

#pages(opts = { account_id: nil, sub_account_id: nil, page_group_id: nil }) ⇒ Object



39
40
41
42
43
# File 'lib/unbounce_client.rb', line 39

def pages(opts={ account_id: nil, sub_account_id: nil, page_group_id: nil })
  parent, id = opts_to_path_and_id(opts)

  parse( get("/#{parent}/#{id}/pages") )['pages'].collect { |page| OpenStruct.new(page) }
end

#rootObject



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

def root
  parse get('/')
end

#sub_account(id) ⇒ Object



27
28
29
# File 'lib/unbounce_client.rb', line 27

def (id)
  OpenStruct.new( parse( get("/sub_accounts/#{id}") ) )
end

#sub_accounts(account_id) ⇒ Object



23
24
25
# File 'lib/unbounce_client.rb', line 23

def sub_accounts()
  parse( get("/accounts/#{account_id}/sub_accounts") )['subAccounts'].collect { || OpenStruct.new() }
end