Class: NutshellCrm::Client
- Inherits:
-
Object
- Object
- NutshellCrm::Client
- Includes:
- HTTParty
- Defined in:
- lib/nutshell-crm.rb
Instance Attribute Summary collapse
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#stub_responses ⇒ Object
Returns the value of attribute stub_responses.
Instance Method Summary collapse
- #add_email(email_string) ⇒ Object
-
#describe_custom_fields ⇒ json
Gets all of the custom fields available for Leads, Accounts and Contacts, including appropriate meta-information.
- #edit_account(account_id, rev, account) ⇒ Object
- #edit_activity(activity_id, rev, activity) ⇒ Object
- #edit_contact(contact_id, rev, contact) ⇒ Object
- #edit_lead(lead_id, rev, lead) ⇒ Object
- #edit_step(step_id, rev, step) ⇒ Object
- #find_account_types(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
- #find_accounts(query, order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil) ⇒ Object
- #find_activities(query, order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil) ⇒ Object
- #find_activity_types(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
- #find_competitors(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
- #find_contacts(query, order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil) ⇒ Object
- #find_delays(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
- #find_industries(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
- #find_lead_outcomes(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
- #find_leads(query, order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil) ⇒ Object
- #find_markets(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
- #find_milestones(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
- #find_origins(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
- #find_products(order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil) ⇒ Object
- #find_settings(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
- #find_sources(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
- #find_tags ⇒ Object
- #find_teams(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
- #find_territories(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
- #find_timeline(query, order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil) ⇒ Object
- #find_users(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
- #get_account(account_id, rev = nil) ⇒ Object
- #get_activity(activity_id, rev = nil) ⇒ Object
- #get_contact(contact_id, rev = nil) ⇒ Object
- #get_email(email_id, rev = nil) ⇒ Object
- #get_lead(lead_id, rev = nil) ⇒ Object
- #get_mobile_settings ⇒ Object
- #get_note(note_id, rev = nil) ⇒ Object
- #get_product(product_id, rev = nil) ⇒ Object
- #get_update_times ⇒ Object
- #get_user(user_id = nil, rev = nil) ⇒ Object
- #getAnalyticsReport(report_type, period, filter_entity = nil, options = nil) ⇒ Object
-
#initialize(username, api_key) ⇒ Client
constructor
A new instance of Client.
- #new_account(account) ⇒ Object
- #new_activity(activity) ⇒ Object
- #new_contact(contact) ⇒ Object
- #new_lead(lead) ⇒ Object
- #new_tag(tag) ⇒ Object
- #search_accounts(query, limit = nil) ⇒ Object
- #search_by_email(email_address) ⇒ Object
- #search_competitors(query, limit = nil) ⇒ Object
- #search_contacts(query, limit = nil) ⇒ Object
- #search_contacts_and_users(query, limit = nil) ⇒ Object
- #search_leads(query, limit = nil) ⇒ Object
- #search_products(query, limit = nil) ⇒ Object
- #search_sources(query, limit = nil) ⇒ Object
- #search_universal(query) ⇒ Object
- #search_users_and_teams(query, limit = nil) ⇒ Object
Constructor Details
#initialize(username, api_key) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 19 20 21 |
# File 'lib/nutshell-crm.rb', line 13 def initialize(username, api_key) @username = username @api_key = api_key @stub_responses = nil result = exec_request(build_payload({:username => @username}), 'http://api.nutshell.com/v1/json') api_host = result['api'] @api_url = "https://#{api_host}/api/v1/json" end |
Instance Attribute Details
#api_url ⇒ Object
Returns the value of attribute api_url.
9 10 11 |
# File 'lib/nutshell-crm.rb', line 9 def api_url @api_url end |
#stub_responses ⇒ Object
Returns the value of attribute stub_responses.
9 10 11 |
# File 'lib/nutshell-crm.rb', line 9 def stub_responses @stub_responses end |
Instance Method Details
#add_email(email_string) ⇒ Object
23 24 25 |
# File 'lib/nutshell-crm.rb', line 23 def add_email(email_string) exec_request build_payload({:emailString => email_string}) end |
#describe_custom_fields ⇒ json
Gets all of the custom fields available for Leads, Accounts and Contacts, including appropriate meta-information.
30 31 32 |
# File 'lib/nutshell-crm.rb', line 30 def describe_custom_fields exec_request build_payload end |
#edit_account(account_id, rev, account) ⇒ Object
34 35 36 |
# File 'lib/nutshell-crm.rb', line 34 def edit_account(account_id, rev, account) exec_request build_payload({:accountId => account_id, :rev => rev, :account => account}) end |
#edit_activity(activity_id, rev, activity) ⇒ Object
38 39 40 |
# File 'lib/nutshell-crm.rb', line 38 def edit_activity(activity_id, rev, activity) exec_request build_payload({:activityId => activity_id, :rev => rev, :activity => activity}) end |
#edit_contact(contact_id, rev, contact) ⇒ Object
42 43 44 |
# File 'lib/nutshell-crm.rb', line 42 def edit_contact(contact_id, rev, contact) exec_request build_payload({:contactId => contact_id, :rev => rev, :contact => contact}) end |
#edit_lead(lead_id, rev, lead) ⇒ Object
46 47 48 |
# File 'lib/nutshell-crm.rb', line 46 def edit_lead(lead_id, rev, lead) exec_request build_payload({:leadId => lead_id, :rev => rev, :lead => lead}) end |
#edit_step(step_id, rev, step) ⇒ Object
50 51 52 |
# File 'lib/nutshell-crm.rb', line 50 def edit_step(step_id, rev, step) exec_request build_payload({:stepId => step_id, :rev => rev, :step => step}) end |
#find_account_types(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
60 61 62 63 64 |
# File 'lib/nutshell-crm.rb', line 60 def find_account_types(order_by = nil, order_direction = nil, limit = nil, page = nil) params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page} payload = build_payload params exec_request(payload) end |
#find_accounts(query, order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil) ⇒ Object
54 55 56 57 58 |
# File 'lib/nutshell-crm.rb', line 54 def find_accounts(query, order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil) params = {:query => query, :orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page, :stubResponses => stub_responses} payload = build_payload params exec_request(payload) end |
#find_activities(query, order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil) ⇒ Object
66 67 68 69 70 |
# File 'lib/nutshell-crm.rb', line 66 def find_activities(query, order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil) params = {:query => query, :orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page, :stubResponses => stub_responses} payload = build_payload params exec_request(payload) end |
#find_activity_types(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
72 73 74 75 76 |
# File 'lib/nutshell-crm.rb', line 72 def find_activity_types(order_by = nil, order_direction = nil, limit = nil, page = nil) params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page} payload = build_payload params exec_request(payload) end |
#find_competitors(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
78 79 80 81 82 |
# File 'lib/nutshell-crm.rb', line 78 def find_competitors(order_by = nil, order_direction = nil, limit = nil, page = nil) params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page} payload = build_payload params exec_request(payload) end |
#find_contacts(query, order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil) ⇒ Object
84 85 86 87 88 |
# File 'lib/nutshell-crm.rb', line 84 def find_contacts(query, order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil) params = {:query => query, :orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page, :stubResponses => stub_responses} payload = build_payload params exec_request(payload) end |
#find_delays(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
90 91 92 93 94 |
# File 'lib/nutshell-crm.rb', line 90 def find_delays(order_by = nil, order_direction = nil, limit = nil, page = nil) params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page} payload = build_payload params exec_request(payload) end |
#find_industries(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
96 97 98 99 100 |
# File 'lib/nutshell-crm.rb', line 96 def find_industries(order_by = nil, order_direction = nil, limit = nil, page = nil) params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page} payload = build_payload params exec_request(payload) end |
#find_lead_outcomes(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
102 103 104 105 106 |
# File 'lib/nutshell-crm.rb', line 102 def find_lead_outcomes(order_by = nil, order_direction = nil, limit = nil, page = nil) params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page} payload = build_payload params, 'findLead_Outcomes' exec_request(payload) end |
#find_leads(query, order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil) ⇒ Object
108 109 110 111 112 |
# File 'lib/nutshell-crm.rb', line 108 def find_leads(query, order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil) params = {:query => query, :orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page, :stubResponses => stub_responses} payload = build_payload params exec_request(payload) end |
#find_markets(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
114 115 116 117 118 |
# File 'lib/nutshell-crm.rb', line 114 def find_markets(order_by = nil, order_direction = nil, limit = nil, page = nil) params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page} payload = build_payload params exec_request(payload) end |
#find_milestones(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
120 121 122 123 124 |
# File 'lib/nutshell-crm.rb', line 120 def find_milestones(order_by = nil, order_direction = nil, limit = nil, page = nil) params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page} payload = build_payload params exec_request(payload) end |
#find_origins(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
126 127 128 129 130 |
# File 'lib/nutshell-crm.rb', line 126 def find_origins(order_by = nil, order_direction = nil, limit = nil, page = nil) params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page} payload = build_payload params exec_request(payload) end |
#find_products(order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil) ⇒ Object
132 133 134 135 136 |
# File 'lib/nutshell-crm.rb', line 132 def find_products(order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil) params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page, :stubResponses => stub_responses} payload = build_payload params exec_request(payload) end |
#find_settings(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
138 139 140 141 142 |
# File 'lib/nutshell-crm.rb', line 138 def find_settings(order_by = nil, order_direction = nil, limit = nil, page = nil) params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page} payload = build_payload params exec_request(payload) end |
#find_sources(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
144 145 146 147 148 |
# File 'lib/nutshell-crm.rb', line 144 def find_sources(order_by = nil, order_direction = nil, limit = nil, page = nil) params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page} payload = build_payload params exec_request(payload) end |
#find_tags ⇒ Object
150 151 152 |
# File 'lib/nutshell-crm.rb', line 150 def exec_request build_payload end |
#find_teams(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
154 155 156 157 158 |
# File 'lib/nutshell-crm.rb', line 154 def find_teams(order_by = nil, order_direction = nil, limit = nil, page = nil) params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page} payload = build_payload params exec_request(payload) end |
#find_territories(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
160 161 162 163 164 |
# File 'lib/nutshell-crm.rb', line 160 def find_territories(order_by = nil, order_direction = nil, limit = nil, page = nil) params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page} payload = build_payload params exec_request(payload) end |
#find_timeline(query, order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil) ⇒ Object
166 167 168 169 170 |
# File 'lib/nutshell-crm.rb', line 166 def find_timeline(query, order_by = nil, order_direction = nil, limit = nil, page = nil, stub_responses = nil) params = {:query => query, :orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page, :stubResponses => stub_responses} payload = build_payload params exec_request(payload) end |
#find_users(order_by = nil, order_direction = nil, limit = nil, page = nil) ⇒ Object
172 173 174 175 176 |
# File 'lib/nutshell-crm.rb', line 172 def find_users(order_by = nil, order_direction = nil, limit = nil, page = nil) params = {:orderBy => order_by, :orderDirection => order_direction, :limit => limit, :page => page} payload = build_payload params exec_request(payload) end |
#get_account(account_id, rev = nil) ⇒ Object
178 179 180 181 |
# File 'lib/nutshell-crm.rb', line 178 def get_account(account_id, rev = nil) params = {:accountId => account_id, :rev => rev} exec_request build_payload(params) end |
#get_activity(activity_id, rev = nil) ⇒ Object
183 184 185 186 |
# File 'lib/nutshell-crm.rb', line 183 def get_activity(activity_id, rev = nil) params = {:activityId => activity_id, :rev => rev} exec_request build_payload(params) end |
#get_contact(contact_id, rev = nil) ⇒ Object
193 194 195 196 |
# File 'lib/nutshell-crm.rb', line 193 def get_contact(contact_id, rev = nil) params = {:contactId => contact_id, :rev => rev} exec_request build_payload(params) end |
#get_email(email_id, rev = nil) ⇒ Object
198 199 200 201 |
# File 'lib/nutshell-crm.rb', line 198 def get_email(email_id, rev = nil) params = {:emailId => email_id, :rev => rev} exec_request build_payload(params) end |
#get_lead(lead_id, rev = nil) ⇒ Object
203 204 205 206 |
# File 'lib/nutshell-crm.rb', line 203 def get_lead(lead_id, rev = nil) params = {:leadId => lead_id, :rev => rev} exec_request build_payload(params) end |
#get_mobile_settings ⇒ Object
208 209 210 |
# File 'lib/nutshell-crm.rb', line 208 def get_mobile_settings exec_request build_payload end |
#get_note(note_id, rev = nil) ⇒ Object
212 213 214 215 |
# File 'lib/nutshell-crm.rb', line 212 def get_note(note_id, rev = nil) params = {:noteId => note_id, :rev => rev} exec_request build_payload(params) end |
#get_product(product_id, rev = nil) ⇒ Object
217 218 219 220 |
# File 'lib/nutshell-crm.rb', line 217 def get_product(product_id, rev = nil) params = {:productId => product_id, :rev => rev} exec_request build_payload(params) end |
#get_update_times ⇒ Object
222 223 224 |
# File 'lib/nutshell-crm.rb', line 222 def get_update_times exec_request build_payload end |
#get_user(user_id = nil, rev = nil) ⇒ Object
226 227 228 229 |
# File 'lib/nutshell-crm.rb', line 226 def get_user(user_id = nil, rev = nil) params = {:userId => user_id, :rev => rev} exec_request build_payload(params) end |
#getAnalyticsReport(report_type, period, filter_entity = nil, options = nil) ⇒ Object
188 189 190 191 |
# File 'lib/nutshell-crm.rb', line 188 def getAnalyticsReport(report_type, period, filter_entity = nil, = nil) params = {:reportType => report_type, :period => period, :filter => filter_entity, :options => } exec_request build_payload(params) end |
#new_account(account) ⇒ Object
231 232 233 |
# File 'lib/nutshell-crm.rb', line 231 def new_account(account) exec_request build_payload({:account => account}) end |
#new_activity(activity) ⇒ Object
235 236 237 |
# File 'lib/nutshell-crm.rb', line 235 def new_activity(activity) exec_request build_payload({:activity => activity}) end |
#new_contact(contact) ⇒ Object
239 240 241 |
# File 'lib/nutshell-crm.rb', line 239 def new_contact(contact) exec_request build_payload({:contact => contact}) end |
#new_lead(lead) ⇒ Object
243 244 245 |
# File 'lib/nutshell-crm.rb', line 243 def new_lead(lead) exec_request build_payload({:lead => lead}) end |
#new_tag(tag) ⇒ Object
247 248 249 |
# File 'lib/nutshell-crm.rb', line 247 def new_tag(tag) exec_request build_payload({:tag => tag}) end |
#search_accounts(query, limit = nil) ⇒ Object
251 252 253 |
# File 'lib/nutshell-crm.rb', line 251 def search_accounts(query, limit = nil) exec_request build_payload({:string => query, :limit => limit}) end |
#search_by_email(email_address) ⇒ Object
255 256 257 |
# File 'lib/nutshell-crm.rb', line 255 def search_by_email(email_address) exec_request build_payload({:emailAddressString => email_address}) end |
#search_competitors(query, limit = nil) ⇒ Object
259 260 261 |
# File 'lib/nutshell-crm.rb', line 259 def search_competitors(query, limit = nil) exec_request build_payload({:string => query, :limit => limit}) end |
#search_contacts(query, limit = nil) ⇒ Object
263 264 265 |
# File 'lib/nutshell-crm.rb', line 263 def search_contacts(query, limit = nil) exec_request build_payload({:string => query, :limit => limit}) end |
#search_contacts_and_users(query, limit = nil) ⇒ Object
267 268 269 |
# File 'lib/nutshell-crm.rb', line 267 def search_contacts_and_users(query, limit = nil) exec_request build_payload({:string => query, :limit => limit}) end |
#search_leads(query, limit = nil) ⇒ Object
271 272 273 |
# File 'lib/nutshell-crm.rb', line 271 def search_leads(query, limit = nil) exec_request build_payload({:string => query, :limit => limit}) end |
#search_products(query, limit = nil) ⇒ Object
275 276 277 |
# File 'lib/nutshell-crm.rb', line 275 def search_products(query, limit = nil) exec_request build_payload({:string => query, :limit => limit}) end |
#search_sources(query, limit = nil) ⇒ Object
279 280 281 |
# File 'lib/nutshell-crm.rb', line 279 def search_sources(query, limit = nil) exec_request build_payload({:string => query, :limit => limit}) end |
#search_universal(query) ⇒ Object
283 284 285 |
# File 'lib/nutshell-crm.rb', line 283 def search_universal(query) exec_request build_payload({:string => query}) end |
#search_users_and_teams(query, limit = nil) ⇒ Object
287 288 289 |
# File 'lib/nutshell-crm.rb', line 287 def search_users_and_teams(query, limit = nil) exec_request build_payload({:string => query, :limit => limit}) end |