class ConvertKit::Client

Attributes

key[R]
uri[R]
version[R]

Public Class Methods

new(key, uri="https://api.convertkit.com") click to toggle source
# File lib/convertkit/client.rb, line 10
def initialize(key, uri="https://api.convertkit.com")
  @key     = key
  @uri     = uri
  @version = 2
end

Public Instance Methods

courses() click to toggle source
# File lib/convertkit/client.rb, line 23
def courses()

end
form(id) click to toggle source
# File lib/convertkit/client.rb, line 16
def form(id)
  form = ConvertKit::Form.new(id)
  form.client = self

  form
end
forms() click to toggle source
# File lib/convertkit/form.rb, line 30
def forms()
  raw   = get_request("/forms")
  forms = []

  raw.each do |raw_form|
    form = ConvertKit::Form.new(raw_form["id"])
    form.load(raw_form, self)

    forms << form
  end

  forms
end

Private Instance Methods

get_request(url) click to toggle source
# File lib/convertkit/client.rb, line 29
def get_request(url)
  json = self.class.get("#{@uri}/#{url}?k=#{@key}&v=#{@version}")
  JSON.parse(json.body)
end