Class: Reloop::Services::Contacts
- Inherits:
-
Object
- Object
- Reloop::Services::Contacts
- Defined in:
- lib/reloop/services/contacts.rb
Instance Attribute Summary collapse
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
Instance Method Summary collapse
- #create(params) ⇒ Object
- #create_group(params) ⇒ Object
- #create_property(params) ⇒ Object
- #delete(contact_id) ⇒ Object
- #delete_group(group_id) ⇒ Object
- #delete_property(property_id) ⇒ Object
- #get(contact_id) ⇒ Object
- #get_group(group_id) ⇒ Object
-
#initialize(client) ⇒ Contacts
constructor
A new instance of Contacts.
- #list(params = {}) ⇒ Object
- #list_groups(params = {}) ⇒ Object
- #list_properties(params = {}) ⇒ Object
- #update(contact_id, params) ⇒ Object
- #update_group(group_id, params) ⇒ Object
- #update_property(property_id, params) ⇒ Object
Constructor Details
#initialize(client) ⇒ Contacts
Returns a new instance of Contacts.
10 11 12 13 14 |
# File 'lib/reloop/services/contacts.rb', line 10 def initialize(client) @client = client @groups = ContactGroups.new(client) @channels = ContactChannels.new(client) end |
Instance Attribute Details
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
8 9 10 |
# File 'lib/reloop/services/contacts.rb', line 8 def channels @channels end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
8 9 10 |
# File 'lib/reloop/services/contacts.rb', line 8 def groups @groups end |
Instance Method Details
#create(params) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/reloop/services/contacts.rb', line 16 def create(params) @client.fetch( :post, "/api/contacts/create", Support::Parameters.for_request(params), ) end |
#create_group(params) ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/reloop/services/contacts.rb', line 81 def create_group(params) @client.fetch( :post, "/api/contacts/v1/groups/create", Support::Parameters.for_request(params), ) end |
#create_property(params) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/reloop/services/contacts.rb', line 52 def create_property(params) @client.fetch( :post, "/api/contacts/v1/properties/create", Support::Parameters.for_request(params), ) end |
#delete(contact_id) ⇒ Object
48 49 50 |
# File 'lib/reloop/services/contacts.rb', line 48 def delete(contact_id) @client.fetch(:delete, "/api/contacts/#{contact_id}") end |
#delete_group(group_id) ⇒ Object
110 111 112 |
# File 'lib/reloop/services/contacts.rb', line 110 def delete_group(group_id) @client.fetch(:delete, "/api/contacts/v1/groups/#{group_id}") end |
#delete_property(property_id) ⇒ Object
77 78 79 |
# File 'lib/reloop/services/contacts.rb', line 77 def delete_property(property_id) @client.fetch(:delete, "/api/contacts/v1/properties/#{property_id}") end |
#get(contact_id) ⇒ Object
24 25 26 |
# File 'lib/reloop/services/contacts.rb', line 24 def get(contact_id) @client.fetch(:get, "/api/contacts/retrieve/#{contact_id}") end |
#get_group(group_id) ⇒ Object
98 99 100 |
# File 'lib/reloop/services/contacts.rb', line 98 def get_group(group_id) @client.fetch(:get, "/api/contacts/v1/groups/#{group_id}") end |
#list(params = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/reloop/services/contacts.rb', line 28 def list(params = {}) query = Support::Parameters.for_query(params) group_id = query["groupId"] || query["group_id"] if group_id filtered = query.reject { |key, _| %w[groupId group_id].include?(key) } return @groups.list_contacts(group_id, filtered) end @client.fetch(:get, "/api/contacts/list", nil, query) end |
#list_groups(params = {}) ⇒ Object
89 90 91 92 93 94 95 96 |
# File 'lib/reloop/services/contacts.rb', line 89 def list_groups(params = {}) @client.fetch( :get, "/api/contacts/v1/groups/list", nil, Support::Parameters.for_query(params), ) end |
#list_properties(params = {}) ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/reloop/services/contacts.rb', line 60 def list_properties(params = {}) @client.fetch( :get, "/api/contacts/v1/properties/list", nil, Support::Parameters.for_query(params), ) end |
#update(contact_id, params) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/reloop/services/contacts.rb', line 40 def update(contact_id, params) @client.fetch( :patch, "/api/contacts/#{contact_id}", Support::Parameters.for_request(params), ) end |
#update_group(group_id, params) ⇒ Object
102 103 104 105 106 107 108 |
# File 'lib/reloop/services/contacts.rb', line 102 def update_group(group_id, params) @client.fetch( :patch, "/api/contacts/v1/groups/#{group_id}", Support::Parameters.for_request(params), ) end |
#update_property(property_id, params) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/reloop/services/contacts.rb', line 69 def update_property(property_id, params) @client.fetch( :patch, "/api/contacts/v1/properties/#{property_id}", Support::Parameters.for_request(params), ) end |