class DoList::Integration

Public Class Methods

new(params = {}) click to toggle source
# File lib/do_list.rb, line 8
def initialize(params = {})
  @account_id = params[:account_id]
  @api_key = params[:api_key]
  @auth_url = 'http://api.dolist.net/v2/AuthenticationService.svc/soap1.1'
  @push_url = 'http://api.dolist.net/V2/ContactManagementService.svc/soap1.1'
  @auth_token = DoList::AuthToken.new(account_id: @account_id,
                                      api_key: @api_key,
                                      url: @auth_url,
                                      headers: create_headers('auth'))
end

Public Instance Methods

auth_key() click to toggle source
# File lib/do_list.rb, line 19
def auth_key
  @auth_token.auth_key
end
push_entry(fields) click to toggle source
# File lib/do_list.rb, line 23
def push_entry(fields)
  entry = DoList::PushEntry.new(auth_token: @auth_token.auth_key,
                                account_id: @account_id,
                                url: @push_url,
                                headers: create_headers('push'))
  entry.push_entry(fields)
end

Private Instance Methods

create_headers(type) click to toggle source
# File lib/do_list.rb, line 33
def create_headers(type)
  path = 'AuthenticationService/GetAuthenticationToken' if type == 'auth'
  path = 'ContactManagementService/SaveContact' if type == 'push'
  {
    'Content-Type' => 'text/xml; charset=utf-8',
    'SOAPAction' => "http://api.dolist.net/v2/#{path}"
  }
end