Class: Thron::Gateway::Contact
- Defined in:
- lib/thron/gateway/contact.rb
Constant Summary collapse
- PACKAGE =
Package.new(:xcontact, :resources, self.service_name)
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #add_contact_key(options = {}) ⇒ Object
- #contact_detail(options = {}) ⇒ Object
- #insert_contact(options = {}) ⇒ Object
- #list_contact_keys(options = {}) ⇒ Object
- #list_contacts(options = {}) ⇒ Object
- #remove_contact_key(options = {}) ⇒ Object
- #update_contact(options = {}) ⇒ Object
Methods inherited from Session
Methods included from Pageable
Methods inherited from Base
#check_session, client_id, #client_id, service_name
Methods included from Routable
Constructor Details
This class inherits a constructor from Thron::Gateway::Session
Class Method Details
.routes ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/thron/gateway/contact.rb', line 13 def self.routes @routes ||= { add_contact_key: Route::factory(name: 'addKey', package: PACKAGE, params: [client_id]), contact_detail: Route::factory(name: 'detail', package: PACKAGE, verb: Route::Verbs::GET, params: [client_id]), insert_contact: Route::factory(name: 'insert', package: PACKAGE, params: [client_id]), list_contacts: Route::factory(name: 'list', package: PACKAGE, params: [client_id]), list_contact_keys: Route::factory(name: 'listKey', package: PACKAGE, params: [client_id]), remove_contact_key: Route::factory(name: 'removeKey', package: PACKAGE, params: [client_id]), update_contact: Route::factory(name: 'update', package: PACKAGE, params: [client_id]) } end |
Instance Method Details
#add_contact_key(options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/thron/gateway/contact.rb', line 25 def add_contact_key( = {}) contact_id = [:contact_id] ik = [:ik] body = { contactId: contact_id, ik: ik } route(to: __callee__, body: body, token_id: token_id) do |response| response.body = Entity::Base::factory(response.body.fetch('item') { {} }) end end |
#contact_detail(options = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/thron/gateway/contact.rb', line 37 def contact_detail( = {}) contact_id = [:contact_id] query = { contactId: contact_id, } route(to: __callee__, query: query, token_id: token_id) do |response| response.body = Entity::Base::factory(response.body.fetch('item') { {} }) end end |
#insert_contact(options = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/thron/gateway/contact.rb', line 47 def insert_contact( = {}) name = [:name] ik = [:ik] body = { value: { ik: ik, name: name } } route(to: __callee__, body: body, token_id: token_id) do |response| response.body = Entity::Base::factory(response.body.fetch('item') { {} }) end end |
#list_contact_keys(options = {}) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/thron/gateway/contact.rb', line 77 def list_contact_keys( = {}) search_key = [:search_key] offset = [:offset].to_i limit = [:limit].to_i body = { criteria: { searchKey: search_key }, offset: offset, limit: limit } route(to: __callee__, body: body, token_id: token_id) do |response| response.body = response.body.fetch('items') { [] } end end |
#list_contacts(options = {}) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/thron/gateway/contact.rb', line 61 def list_contacts( = {}) criteria = .fetch(:criteria) { {} } option = .fetch(:option) { {} } offset = [:offset].to_i limit = [:limit].to_i body = { criteria: criteria, option: option, offset: offset, limit: limit } route(to: __callee__, body: body, token_id: token_id) do |response| response.body = Entity::Base::factory(response.body.fetch('items') { [] }) end end |
#remove_contact_key(options = {}) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/thron/gateway/contact.rb', line 93 def remove_contact_key( = {}) contact_id = [:contact_id] key = [:key] body = { contactId: contact_id, key: key } route(to: __callee__, body: body, token_id: token_id) do |response| response.body = Entity::Base::factory(response.body.fetch('item') { {} }) end end |
#update_contact(options = {}) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/thron/gateway/contact.rb', line 105 def update_contact( = {}) contact_id = [:contact_id] name = [:name] body = { contactId: contact_id, update: { name: name } } route(to: __callee__, body: body, token_id: token_id) do |response| response.body = Entity::Base::factory(response.body.fetch('item') { {} }) end end |