Class: Closeio::Client

Inherits:
Object
  • Object
show all
Includes:
Activity, BulkAction, Contact, CustomField, EmailAccount, EmailTemplate, Event, IntegrationLink, Lead, LeadStatus, Opportunity, OpportunityStatus, Organization, Report, Sequence, SequenceSchedule, SequenceSubscription, SmartView, Task, User, Webhook
Defined in:
lib/closeio/client.rb,
lib/closeio/resources/lead.rb,
lib/closeio/resources/task.rb,
lib/closeio/resources/user.rb,
lib/closeio/resources/event.rb,
lib/closeio/resources/report.rb,
lib/closeio/resources/contact.rb,
lib/closeio/resources/webhook.rb,
lib/closeio/resources/activity.rb,
lib/closeio/resources/sequence.rb,
lib/closeio/resources/smart_view.rb,
lib/closeio/resources/bulk_action.rb,
lib/closeio/resources/lead_status.rb,
lib/closeio/resources/opportunity.rb,
lib/closeio/resources/custom_field.rb,
lib/closeio/resources/organization.rb,
lib/closeio/resources/email_account.rb,
lib/closeio/resources/email_template.rb,
lib/closeio/resources/integration_link.rb,
lib/closeio/resources/sequence_schedule.rb,
lib/closeio/resources/opportunity_status.rb,
lib/closeio/resources/sequence_subscription.rb

Defined Under Namespace

Modules: Activity, BulkAction, Contact, CustomField, EmailAccount, EmailTemplate, Event, IntegrationLink, Lead, LeadStatus, Opportunity, OpportunityStatus, Organization, Report, Sequence, SequenceSchedule, SequenceSubscription, SmartView, Task, User, Webhook

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Webhook

#create_webhook, #delete_webhook, #find_webhook, #list_webhooks, #update_webhook

Methods included from User

#available_users, #fetch_api_key, #find_user, #list_users, #me

Methods included from Task

#create_task, #delete_task, #find_task, #list_tasks, #update_task

Methods included from SmartView

#create_smart_view, #delete_smart_view, #find_smart_view, #list_smart_views, #update_smart_view

Methods included from SequenceSubscription

#create_sequence_subscription, #find_sequence_subscription, #list_sequence_subscriptions, #update_sequence_subscription

Methods included from SequenceSchedule

#find_sequence_schedule, #list_sequence_schedules

Methods included from Sequence

#create_sequence, #delete_sequence, #find_sequence, #list_sequences, #update_sequence

Methods included from Report

#activity_report, #lead_status_report, #sent_emails_report

Methods included from Organization

#find_organization, #update_organization

Methods included from OpportunityStatus

#create_opportunity_status, #delete_opportunity_status, #list_opportunity_statuses, #update_opportunity_status

Methods included from Opportunity

#create_opportunity, #delete_opportunity, #find_opportunity, #list_opportunities, #update_opportunity

Methods included from LeadStatus

#create_lead_status, #delete_lead_status, #list_lead_statuses, #update_lead_status

Methods included from Lead

#create_lead, #delete_lead, #find_lead, #list_leads, #merge_leads, #update_lead

Methods included from IntegrationLink

#create_integration_link, #delete_integration_link, #find_integration_link, #list_integration_links, #update_integration_link

Methods included from Event

#list_events

Methods included from EmailTemplate

#create_email_template, #delete_email_template, #find_email_template, #list_email_templates, #render_email_templates, #update_email_template

Methods included from EmailAccount

#list_email_accounts

Methods included from CustomField

#create_custom_field, #delete_custom_field, #find_custom_field, #list_custom_fields, #update_custom_field

Methods included from Contact

#create_contact, #delete_contact, #find_contact, #list_contacts, #update_contact

Methods included from BulkAction

#bulk_delete, #bulk_edit, #list_bulk_emails, #send_bulk_email

Methods included from Activity

#create_call, #create_email, #create_note, #delete_call, #delete_email, #delete_emailthread, #delete_note, #find_email, #find_emailthread, #find_note, #list_activities, #list_calls, #list_emails, #list_emailthreads, #list_notes, #update_email, #update_note

Constructor Details

#initialize(api_key, logger = true, ca_file = nil, errors = false, utc_offset: 0) ⇒ Client

Returns a new instance of Client.



34
35
36
37
38
39
40
# File 'lib/closeio/client.rb', line 34

def initialize(api_key, logger = true, ca_file = nil, errors = false, utc_offset: 0)
  @api_key = api_key
  @logger  = logger
  @ca_file = ca_file
  @errors  = errors
  @utc_offset = utc_offset
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



32
33
34
# File 'lib/closeio/client.rb', line 32

def api_key
  @api_key
end

#ca_fileObject (readonly)

Returns the value of attribute ca_file.



32
33
34
# File 'lib/closeio/client.rb', line 32

def ca_file
  @ca_file
end

#errorsObject (readonly)

Returns the value of attribute errors.



32
33
34
# File 'lib/closeio/client.rb', line 32

def errors
  @errors
end

#loggerObject (readonly)

Returns the value of attribute logger.



32
33
34
# File 'lib/closeio/client.rb', line 32

def logger
  @logger
end

#utc_offsetObject (readonly)

Returns the value of attribute utc_offset.



32
33
34
# File 'lib/closeio/client.rb', line 32

def utc_offset
  @utc_offset
end

Instance Method Details

#delete(path, options = {}) ⇒ Object



57
58
59
# File 'lib/closeio/client.rb', line 57

def delete(path, options = {})
  connection.delete(path, options).body
end

#get(path, options = {}) ⇒ Object



42
43
44
# File 'lib/closeio/client.rb', line 42

def get(path, options = {})
  connection.get(path, options).body
end

#paginate(path, options = {}) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/closeio/client.rb', line 61

def paginate(path, options = {})
  results = []
  skip    = 0

  begin
    res = get(path, options.merge!(_skip: skip))
    unless res['data'].nil? || res['data'].empty?
      results.push res['data']
      skip += res['data'].count
    end
  end while res['has_more']
  { has_more: false, total_results: res['total_results'], data: results.flatten }
end

#post(path, req_body) ⇒ Object



46
47
48
49
50
51
# File 'lib/closeio/client.rb', line 46

def post(path, req_body)
  connection.post do |req|
    req.url(path)
    req.body = req_body
  end.body
end

#put(path, options = {}) ⇒ Object



53
54
55
# File 'lib/closeio/client.rb', line 53

def put(path, options = {})
  connection.put(path, options).body
end