Class: Desk::Client
- Inherits:
-
API
- Object
- API
- Desk::Client
- Includes:
- Article, Brand, Case, Company, CustomField, Customer, FacebookUser, Filter, Group, Insight, IntegrationUrl, Job, Label, Macro, Mailbox, Rule, SiteSetting, SystemMessage, Topic, TwitterAccount, TwitterUser, User
- Defined in:
- lib/desk/client.rb,
lib/desk/client/job.rb,
lib/desk/client/case.rb,
lib/desk/client/rule.rb,
lib/desk/client/user.rb,
lib/desk/client/brand.rb,
lib/desk/client/group.rb,
lib/desk/client/label.rb,
lib/desk/client/macro.rb,
lib/desk/client/topic.rb,
lib/desk/client/filter.rb,
lib/desk/client/article.rb,
lib/desk/client/company.rb,
lib/desk/client/insight.rb,
lib/desk/client/mailbox.rb,
lib/desk/client/customer.rb,
lib/desk/client/custom_field.rb,
lib/desk/client/site_setting.rb,
lib/desk/client/twitter_user.rb,
lib/desk/client/facebook_user.rb,
lib/desk/client/system_message.rb,
lib/desk/client/integration_url.rb,
lib/desk/client/twitter_account.rb
Overview
All methods have been separated into modules and follow the same grouping used in the Desk.com API Documentation.
Wrapper for the Desk.com REST API
Defined Under Namespace
Modules: Article, Brand, Case, Company, CustomField, Customer, FacebookUser, Filter, Group, Insight, IntegrationUrl, Job, Label, Macro, Mailbox, Rule, SiteSetting, SystemMessage, Topic, TwitterAccount, TwitterUser, User
Constant Summary
Constants included from Request
Instance Method Summary collapse
- #create_link(type, class_or_hash, id = nil, sub_class = nil, sub_id = nil) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #plural(singular) ⇒ Object
Methods included from User
Methods included from TwitterUser
Methods included from TwitterAccount
Methods included from Topic
Methods included from SystemMessage
#show_system_message, #system_message_id
Methods included from SiteSetting
Methods included from Rule
Methods included from Mailbox
#mailbox_id_inbound, #mailbox_list_inbound, #mailbox_show_inbound
Methods included from Macro
Methods included from Label
Methods included from Job
Methods included from IntegrationUrl
Methods included from Insight
#create_insights_report, #show_insights_meta
Methods included from Group
Methods included from Filter
Methods included from FacebookUser
Methods included from Customer
#customer_add_address, #customer_add_email, #customer_add_key, #customer_add_phone_number, #customer_delete_address, #customer_delete_email, #customer_delete_key, #customer_delete_phone_number, #customer_endpoints
Methods included from CustomField
Methods included from Company
Methods included from Case
#case_endpoints, #case_url, #create_case_message_attachment, #create_case_reply_attachment, #delete_case_message_attachment, #delete_case_reply_attachment, #list_case_message_attachments, #list_case_reply_attachments, #show_case, #show_case_message, #show_case_message_attachment, #show_case_reply_attachment
Methods included from Brand
Methods included from Article
Methods included from Request
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/desk/client.rb', line 59 def initialize(={}) if !self.respond_to? :endpoints_setup self.class.included_modules.each do |m| if r = m.name.match(/Desk::Client::([a-zA-z]+)/) base = r[1].gsub(/(.)([A-Z])/, '\1_\2').downcase if self.respond_to? "#{base}_endpoints" endpoints_list = send("#{base}_endpoints") setup_functions(base, endpoints_list) end end end self.class.send(:define_method, :endpoints_setup) {} end super() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Desk::Request
Instance Method Details
#create_link(type, class_or_hash, id = nil, sub_class = nil, sub_id = nil) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/desk/client.rb', line 85 def create_link(type, class_or_hash, id = nil, sub_class = nil, sub_id = nil) if class_or_hash.class == Hashie::Deash {type.to_sym => { :class => class_or_hash._links.self['class'], :href => class_or_hash._links.self['href'] }} elsif class_or_hash.class == String href = Desk.api_path+plural(class_or_hash)+"/#{id}" href += "/"+plural(sub_class)+"/#{sub_id}" if sub_class != nil {type.to_sym => { :class => class_or_hash, :href => href }} else nil end end |
#plural(singular) ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/desk/client.rb', line 75 def plural(singular) if singular[-1, 1] == "y" singular[0..-2]+"ies" elsif singular[-1, 1] == "x" singular+"es" else singular+"s" end end |