Class: Closeio::Client

Inherits:
Object
  • Object
show all
Includes:
Activity, BulkAction, Contact, CustomActivity, CustomActivityType, CustomField, EmailAccount, EmailTemplate, Event, Filter, 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/filter.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/custom_activity.rb,
lib/closeio/resources/integration_link.rb,
lib/closeio/resources/sequence_schedule.rb,
lib/closeio/resources/opportunity_status.rb,
lib/closeio/resources/custom_activity_type.rb,
lib/closeio/resources/sequence_subscription.rb

Defined Under Namespace

Modules: Activity, BulkAction, Contact, CustomActivity, CustomActivityType, CustomField, EmailAccount, EmailTemplate, Event, Filter, 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 Filter

#filter

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

#find_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 CustomActivityType

#find_custom_activity_type, #list_custom_activity_types

Methods included from CustomActivity

#create_custom_activity, #delete_custom_activity, #find_custom_activity, #list_custom_activities, #update_custom_activity

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, #create_sms, #delete_call, #delete_email, #delete_emailthread, #delete_note, #delete_sms, #find_call, #find_email, #find_emailthread, #find_note, #find_sms, #list_activities, #list_calls, #list_emails, #list_emailthreads, #list_meetings, #list_notes, #list_sms, #update_call, #update_email, #update_note, #update_sms

Constructor Details

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

Returns a new instance of Client.



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

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.



34
35
36
# File 'lib/closeio/client.rb', line 34

def api_key
  @api_key
end

#ca_fileObject (readonly)

Returns the value of attribute ca_file.



34
35
36
# File 'lib/closeio/client.rb', line 34

def ca_file
  @ca_file
end

#errorsObject (readonly)

Returns the value of attribute errors.



34
35
36
# File 'lib/closeio/client.rb', line 34

def errors
  @errors
end

#loggerObject (readonly)

Returns the value of attribute logger.



34
35
36
# File 'lib/closeio/client.rb', line 34

def logger
  @logger
end

#utc_offsetObject (readonly)

Returns the value of attribute utc_offset.



34
35
36
# File 'lib/closeio/client.rb', line 34

def utc_offset
  @utc_offset
end

Instance Method Details

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



59
60
61
# File 'lib/closeio/client.rb', line 59

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

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



44
45
46
# File 'lib/closeio/client.rb', line 44

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

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



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

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



48
49
50
51
52
53
# File 'lib/closeio/client.rb', line 48

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

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



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

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