moxiworks_platform 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f278e1a919743a23212ed85372496a5a0dbb1548
4
- data.tar.gz: 09a94c3a6f1ff0781cafa1eed0da74b1f46954f0
3
+ metadata.gz: b5982efd3cf0e8359789a16eb2da72383ed3724d
4
+ data.tar.gz: 9afe87288ef28f30509d1ebd01c68950d2daf91c
5
5
  SHA512:
6
- metadata.gz: 2d8359b4716ff34c27eb807f08eacd2c2b0c0c0224779ce8e23405c6eaa4c99f64710128f74d801e22d52831c67e508f3afa320a9d6cbf12fb5766d354eb791e
7
- data.tar.gz: ea3eb6c0705395285192175c48824aa55eb58ee7d70194a7cb160f6429fb360a7584ba504d326aa4c42c45b00f013f84e7bcd71b205cdb7308069383172c1cd4
6
+ metadata.gz: c0003810df1a747a898f06abc2c3e52986ff014a46b7be4b41e9b3a904f48cb3baba4fd53151c6f21c4db0e94c148bb326fd14c54507c11d7ef086b88ac5e056
7
+ data.tar.gz: 74f2f0903418aa1078ecbea64b468a2bfd81a6d59ef7b907f975928484361098710f7e1e89fbb4ab2914abe50e16f42df5fc3db04196bb0412bf0af5fe9c0bfd
@@ -10,6 +10,7 @@ require 'moxiworks_platform/group'
10
10
  require 'moxiworks_platform/action_log'
11
11
  require 'moxiworks_platform/task'
12
12
  require 'moxiworks_platform/email_campaign'
13
+ require 'moxiworks_platform/company'
13
14
 
14
15
 
15
16
 
@@ -58,7 +58,7 @@ module MoxiworksPlatform
58
58
  # @option opts [String] :moxi_works_agent_id *REQUIRED* The Moxi Works Agent ID for the agent to which this ActionLog is associated
59
59
  # @option opts [String] :partner_contact_id *REQUIRED* Your system's unique ID for the contact for whom the ActionLog entry is being created.
60
60
  #
61
- # @return [Array] containing MoxiworksPlatform::ActionLog objects formatted as follows:
61
+ # @return [Array] containing MoxiworksPlatform::ActionLog objects
62
62
  #
63
63
  # @raise ::MoxiworksPlatform::Exception::ArgumentError if required
64
64
  # named parameters aren't included
@@ -69,6 +69,8 @@ module MoxiworksPlatform
69
69
  # )
70
70
  #
71
71
  def self.search(opts={})
72
+ raise ::MoxiworksPlatform::Exception::ArgumentError,
73
+ 'arguments must be passed as named parameters' unless opts.is_a? Hash
72
74
  url ||= "#{MoxiworksPlatform::Config.url}/api/action_logs"
73
75
  required_opts = [:moxi_works_agent_id, :partner_contact_id]
74
76
  required_opts.each do |opt|
@@ -105,6 +107,8 @@ module MoxiworksPlatform
105
107
  # named parameters aren't included
106
108
  #
107
109
  def self.send_request(method, opts={}, url=nil)
110
+ raise ::MoxiworksPlatform::Exception::ArgumentError,
111
+ 'arguments must be passed as named parameters' unless opts.is_a? Hash
108
112
  url ||= "#{MoxiworksPlatform::Config.url}/api/action_logs"
109
113
  required_opts = [:moxi_works_agent_id, :partner_contact_id, :title, :body]
110
114
  required_opts.each do |opt|
@@ -168,6 +168,8 @@ module MoxiworksPlatform
168
168
  def self.send_request(method, opts={}, url=nil)
169
169
  url ||= "#{MoxiworksPlatform::Config.url}/api/agents"
170
170
  required_opts = [:moxi_works_agent_id]
171
+ raise ::MoxiworksPlatform::Exception::ArgumentError,
172
+ 'arguments must be passed as named parameters' unless opts.is_a? Hash
171
173
  required_opts.each do |opt|
172
174
  raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if
173
175
  opts[opt].nil? or opts[opt].to_s.empty?
@@ -175,6 +177,57 @@ module MoxiworksPlatform
175
177
  super(method, opts, url)
176
178
  end
177
179
 
180
+ # Search For Agents in Moxi Works Platform
181
+ # @param [Hash] opts named parameter Hash
182
+ # @option opts [String] :moxi_works_company_id *REQUIRED* The Moxi Works Company ID For the search (use Company.search to determine available moxi_works_company_id)
183
+ # @option opts [Integer] :updated_since *REQUIRED* Unix timestamp; Only Agents updated after this date will be returned
184
+ #
185
+ #
186
+ # optional Search parameters
187
+ #
188
+ # @option opts [Integer] :page_number the page of results to return
189
+ #
190
+ # @return [Hash] with the format:
191
+ # {
192
+ # page_number: [Integer],
193
+ # total_pages: [Integer],
194
+ # agents: [Array] containing MoxiworkPlatform::Agent objects
195
+ # }
196
+ #
197
+ #
198
+ # @raise ::MoxiworksPlatform::Exception::ArgumentError if required
199
+ # named parameters aren't included
200
+ #
201
+ # @example
202
+ # results = MoxiworksPlatform::Agent.search(
203
+ # moxi_works_company_id: 'the_company',
204
+ # updated_since: Time.now.to_i - 1296000,
205
+ # page_number: 2
206
+ # )
207
+ #
208
+ def self.search(opts={})
209
+ url ||= "#{MoxiworksPlatform::Config.url}/api/agents"
210
+ required_opts = [:moxi_works_company_id, :updated_since]
211
+ required_opts.each do |opt|
212
+ raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if
213
+ opts[opt].nil? or opts[opt].to_s.empty?
214
+ end
215
+ results = []
216
+ json = { 'page_number': 1, 'total_pages': 0, 'tasks':[]}
217
+ RestClient::Request.execute(method: :get,
218
+ url: url,
219
+ payload: opts, headers: self.headers) do |response|
220
+ puts response if MoxiworksPlatform::Config.debug
221
+ self.check_for_error_in_response(response)
222
+ json = JSON.parse(response)
223
+ json['agents'].each do |r|
224
+ results << MoxiworksPlatform::Agent.new(r) unless r.nil? or r.empty?
225
+ end
226
+ json['agents'] = results
227
+ end
228
+ json
229
+ end
230
+
178
231
 
179
232
  end
180
233
 
@@ -0,0 +1,73 @@
1
+ module MoxiworksPlatform
2
+ # = Moxi Works Platform Company
3
+ class Company < MoxiworksPlatform::Resource
4
+
5
+ # @!attribute moxi_works_company_id
6
+ # moxi_works_company_id is the Moxi Works Platform ID of the company
7
+ #
8
+ # @return [String] the Moxi Works Platform ID of the company
9
+ attr_accessor :moxi_works_company_id
10
+
11
+ # @!attribute name
12
+ # the human readable name of this Company
13
+ #
14
+ # @return [String] the human readable name of the company
15
+ attr_accessor :name
16
+
17
+ # Find a Company by ID in Moxi Works Platform
18
+ # @param [Hash] opts named parameter Hash
19
+ # @option opts [String] :moxi_works_company_id *REQUIRED* The Moxi Works Company ID
20
+ #
21
+ # @return [MoxiworksPlatform::Company]
22
+ #
23
+ # @raise ::MoxiworksPlatform::Exception::ArgumentError if required
24
+ # named parameters aren't included
25
+ #
26
+ def self.find(opts={})
27
+ raise ::MoxiworksPlatform::Exception::ArgumentError,
28
+ 'arguments must be passed as named parameters' unless opts.is_a? Hash
29
+ required_opts = [:moxi_works_company_id]
30
+ required_opts.each do |opt|
31
+ raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if
32
+ opts[opt].nil? or opts[opt].to_s.empty?
33
+ end
34
+ url = "#{MoxiworksPlatform::Config.url}/api/companies/#{opts[:moxi_works_company_id]}"
35
+ self.send_request(:get, opts, url)
36
+ end
37
+
38
+
39
+ # Show all my Companies in Moxi Works Platform
40
+ #
41
+ # @return [Array] containing MoxiworksPlatform::Companies objects
42
+ #
43
+ # @raise ::MoxiworksPlatform::Exception::ArgumentError if required
44
+ # named parameters aren't included
45
+ #
46
+ # @example
47
+ # results = MoxiworksPlatform::Companies.search
48
+ #
49
+ def self.search(opts={})
50
+ raise ::MoxiworksPlatform::Exception::ArgumentError,
51
+ 'arguments must be passed as named parameters' unless opts.is_a? Hash
52
+ url ||= "#{MoxiworksPlatform::Config.url}/api/companies"
53
+ required_opts = []
54
+ required_opts.each do |opt|
55
+ raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if
56
+ opts[opt].nil? or opts[opt].to_s.empty?
57
+ end
58
+ results = []
59
+ RestClient::Request.execute(method: :get,
60
+ url: url,
61
+ payload: opts, headers: self.headers) do |response|
62
+ puts response if MoxiworksPlatform::Config.debug
63
+ self.check_for_error_in_response(response)
64
+ json = JSON.parse(response)
65
+ json.each do |r|
66
+ results << MoxiworksPlatform::Company.new(r) unless r.nil? or r.empty?
67
+ end
68
+ end
69
+ results
70
+ end
71
+
72
+ end
73
+ end
@@ -670,6 +670,8 @@ module MoxiworksPlatform
670
670
  # @return [MoxiworksPlatform::Contact]
671
671
  #
672
672
  def self.send_request(method, opts={}, url=nil)
673
+ raise ::MoxiworksPlatform::Exception::ArgumentError,
674
+ 'arguments must be passed as named parameters' unless opts.is_a? Hash
673
675
  url ||= "#{MoxiworksPlatform::Config.url}/api/contacts"
674
676
  required_opts = [:moxi_works_agent_id, :partner_contact_id]
675
677
  required_opts.each do |opt|
@@ -77,6 +77,8 @@ module MoxiworksPlatform
77
77
  # )
78
78
  #
79
79
  def self.search(opts={})
80
+ raise ::MoxiworksPlatform::Exception::ArgumentError,
81
+ 'arguments must be passed as named parameters' unless opts.is_a? Hash
80
82
  url ||= "#{MoxiworksPlatform::Config.url}/api/email_campaigns"
81
83
  required_opts = [:moxi_works_agent_id, :partner_contact_id]
82
84
  required_opts.each do |opt|
@@ -154,6 +154,8 @@ module MoxiworksPlatform
154
154
  # )
155
155
  #
156
156
  def self.search(opts={})
157
+ raise ::MoxiworksPlatform::Exception::ArgumentError,
158
+ 'arguments must be passed as named parameters' unless opts.is_a? Hash
157
159
  url ||= "#{MoxiworksPlatform::Config.url}/api/events"
158
160
  required_opts = [:moxi_works_agent_id, :date_start, :date_end]
159
161
  required_opts.each do |opt|
@@ -239,6 +241,8 @@ module MoxiworksPlatform
239
241
  # success = MoxiWorksPlatform::Event.delete(moxi_works_agent_id: '123abcd', partner_event_id: 'myUniqueEventId' )
240
242
  #
241
243
  def self.delete(opts={})
244
+ raise ::MoxiworksPlatform::Exception::ArgumentError,
245
+ 'arguments must be passed as named parameters' unless opts.is_a? Hash
242
246
  url = "#{MoxiworksPlatform::Config.url}/api/events/#{opts[:partner_event_id]}"
243
247
  required_opts = [:moxi_works_agent_id, :partner_event_id]
244
248
  required_opts.each do |opt|
@@ -283,6 +287,8 @@ module MoxiworksPlatform
283
287
  # named parameters aren't included
284
288
  #
285
289
  def self.send_request(method, opts={}, url=nil)
290
+ raise ::MoxiworksPlatform::Exception::ArgumentError,
291
+ 'arguments must be passed as named parameters' unless opts.is_a? Hash
286
292
  url ||= "#{MoxiworksPlatform::Config.url}/api/events"
287
293
  required_opts = [:moxi_works_agent_id, :partner_event_id]
288
294
  required_opts.each do |opt|
@@ -69,6 +69,8 @@ module MoxiworksPlatform
69
69
  # )
70
70
  #
71
71
  def self.search(opts={})
72
+ raise ::MoxiworksPlatform::Exception::ArgumentError,
73
+ 'arguments must be passed as named parameters' unless opts.is_a? Hash
72
74
  url ||= "#{MoxiworksPlatform::Config.url}/api/groups"
73
75
  required_opts = [:moxi_works_agent_id]
74
76
  required_opts.each do |opt|
@@ -103,6 +105,8 @@ module MoxiworksPlatform
103
105
 
104
106
  protected
105
107
  def self.send_request(method, opts={}, url=nil)
108
+ raise ::MoxiworksPlatform::Exception::ArgumentError,
109
+ 'arguments must be passed as named parameters' unless opts.is_a? Hash
106
110
  url ||= "#{MoxiworksPlatform::Config.url}/api/agents"
107
111
  required_opts = [:moxi_works_agent_id]
108
112
  required_opts.each do |opt|
@@ -1,5 +1,6 @@
1
1
  require 'rest-client'
2
2
  require 'base64'
3
+ require 'json'
3
4
 
4
5
  module MoxiworksPlatform
5
6
  # provides underlying logic for connecting to Moxi Works Platform over HTTPS
@@ -172,6 +172,8 @@ module MoxiworksPlatform
172
172
  # )
173
173
  #
174
174
  def self.search(opts={})
175
+ raise ::MoxiworksPlatform::Exception::ArgumentError,
176
+ 'arguments must be passed as named parameters' unless opts.is_a? Hash
175
177
  url ||= "#{MoxiworksPlatform::Config.url}/api/tasks"
176
178
  required_opts = [:moxi_works_agent_id, :due_date_start, :due_date_end]
177
179
  required_opts.each do |opt|
@@ -260,6 +262,8 @@ module MoxiworksPlatform
260
262
  # named parameters aren't included
261
263
  #
262
264
  def self.send_request(method, opts={}, url=nil)
265
+ raise ::MoxiworksPlatform::Exception::ArgumentError,
266
+ 'arguments must be passed as named parameters' unless opts.is_a? Hash
263
267
  url ||= "#{MoxiworksPlatform::Config.url}/api/tasks"
264
268
  required_opts = [:moxi_works_agent_id, :partner_task_id]
265
269
  required_opts.each do |opt|
@@ -1,3 +1,3 @@
1
1
  module MoxiworksPlatform
2
- VERSION = '0.7.0'
2
+ VERSION = '0.8.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moxiworks_platform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tres Wong-Godfrey
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-18 00:00:00.000000000 Z
11
+ date: 2016-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -85,6 +85,7 @@ files:
85
85
  - lib/moxiworks_platform.rb
86
86
  - lib/moxiworks_platform/action_log.rb
87
87
  - lib/moxiworks_platform/agent.rb
88
+ - lib/moxiworks_platform/company.rb
88
89
  - lib/moxiworks_platform/config.rb
89
90
  - lib/moxiworks_platform/contact.rb
90
91
  - lib/moxiworks_platform/credentials.rb
@@ -120,4 +121,3 @@ signing_key:
120
121
  specification_version: 4
121
122
  summary: Ruby Moxi Works Platform Client
122
123
  test_files: []
123
- has_rdoc: