moxiworks_platform 0.4.3 → 0.5.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 +4 -4
- data/lib/moxiworks_platform.rb +1 -0
- data/lib/moxiworks_platform/action_log.rb +117 -0
- data/lib/moxiworks_platform/group.rb +13 -6
- data/lib/moxiworks_platform/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 072579124ac364093cd09aa3d4f38f51c9e989f3
|
4
|
+
data.tar.gz: df8c6f749772c71cea209cfb680e383f816541fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92e57d0bb040aaf014780ec238c2ab823276151d01cf8f178eef3af957e0b6e80df4062a0b2955ad0ab49d8c28bf02b105a20498415ee8b5c72f3378f9ce3d5a
|
7
|
+
data.tar.gz: ccb695f90ae5533724c320871a6803eb9f81040e234ec9287d039c6220924a0fa9ca6911d2b919f47b721c3d14c07969d942604eb13010e69db0b9d4dc18bc3d
|
data/lib/moxiworks_platform.rb
CHANGED
@@ -0,0 +1,117 @@
|
|
1
|
+
module MoxiworksPlatform
|
2
|
+
class ActionLog < MoxiworksPlatform::Resource
|
3
|
+
# @!attribute moxi_works_agent_id
|
4
|
+
# moxi_works_agent_id is the Moxi Works Platform ID of the agent which an ActionLog entry is
|
5
|
+
# or is to be associated with.
|
6
|
+
#
|
7
|
+
# this must be set for any Moxi Works Platform transaction
|
8
|
+
#
|
9
|
+
# @return [String] the Moxi Works Platform ID of the agent
|
10
|
+
attr_accessor :moxi_works_agent_id
|
11
|
+
|
12
|
+
# @!attribute partner_contact_id
|
13
|
+
# *your system's* unique ID for the Contact
|
14
|
+
#
|
15
|
+
# this must be set for any Moxi Works Platform transaction
|
16
|
+
#
|
17
|
+
# @return [String] your system's unique ID for the contact
|
18
|
+
attr_accessor :partner_contact_id
|
19
|
+
|
20
|
+
# @!attribute title
|
21
|
+
# the title to be displayed for this ActionLog Entry
|
22
|
+
#
|
23
|
+
# @return [String] -- Default ''
|
24
|
+
attr_accessor :title
|
25
|
+
|
26
|
+
# @!attribute body
|
27
|
+
# the body of the log entry to be displayed for this ActionLog Entry
|
28
|
+
#
|
29
|
+
# @return [String] -- Default ''
|
30
|
+
attr_accessor :body
|
31
|
+
|
32
|
+
# Creates a new ActionLog entry in Moxi Works Platform
|
33
|
+
# @param [Hash] opts named parameter Hash
|
34
|
+
# @option opts [String] :moxi_works_agent_id *REQUIRED* The Moxi Works Agent ID for the agent to which this ActionLog entry is to be associated
|
35
|
+
# @option opts [String] :partner_contact_id *REQUIRED* Your system's unique ID for the contact for whom the ActionLog entry is being created.
|
36
|
+
# @option opts [String] :title *REQUIRED* A brief title for this ActionLog entry (85 characters or less)
|
37
|
+
# @option opts [String] :body *REQUIRED* The body of this ActionLog entry (255 characters or less)
|
38
|
+
#
|
39
|
+
# @return [MoxiworksPlatform::ActionLog]
|
40
|
+
#
|
41
|
+
# @raise ::MoxiworksPlatform::Exception::ArgumentError if required
|
42
|
+
# named parameters aren't included
|
43
|
+
#
|
44
|
+
# @example
|
45
|
+
# MoxiworksPlatform::ActionLog.create(
|
46
|
+
# moxi_works_agent_id: 'abc123',
|
47
|
+
# partner_contact_id: 'mySystemsUniqueContactID',
|
48
|
+
# title: 'New home keys were delivered to Firstname Lastname',
|
49
|
+
# body: 'Firstname Lastname were delivered their keys to1234 there ave',
|
50
|
+
# )
|
51
|
+
#
|
52
|
+
def self.create(opts={})
|
53
|
+
self.send_request(:post, opts)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Search an Agent's ActionLog entries in Moxi Works Platform
|
57
|
+
# @param [Hash] opts named parameter Hash
|
58
|
+
# @option opts [String] :moxi_works_agent_id *REQUIRED* The Moxi Works Agent ID for the agent to which this ActionLog is associated
|
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
|
+
#
|
61
|
+
# @return [Array] containing MoxiworksPlatform::ActionLog objects formatted as follows:
|
62
|
+
#
|
63
|
+
# @raise ::MoxiworksPlatform::Exception::ArgumentError if required
|
64
|
+
# named parameters aren't included
|
65
|
+
#
|
66
|
+
# @example
|
67
|
+
# results = MoxiworksPlatform::ActionLog.search(
|
68
|
+
# moxi_works_agent_id: '123abc',
|
69
|
+
# )
|
70
|
+
#
|
71
|
+
def self.search(opts={})
|
72
|
+
url ||= "#{MoxiworksPlatform::Config.url}/api/action_logs"
|
73
|
+
required_opts = [:moxi_works_agent_id, :partner_contact_id]
|
74
|
+
required_opts.each do |opt|
|
75
|
+
raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if
|
76
|
+
opts[opt].nil? or opts[opt].empty?
|
77
|
+
end
|
78
|
+
results = []
|
79
|
+
RestClient::Request.execute(method: :get,
|
80
|
+
url: url,
|
81
|
+
payload: opts, headers: self.headers) do |response|
|
82
|
+
puts response if MoxiworksPlatform::Config.debug
|
83
|
+
self.check_for_error_in_response(response)
|
84
|
+
json = JSON.parse(response)
|
85
|
+
json['actions'].each do |r|
|
86
|
+
results << MoxiworksPlatform::ActionLog.new(r) unless r.nil? or r.empty?
|
87
|
+
end
|
88
|
+
end
|
89
|
+
results
|
90
|
+
end
|
91
|
+
|
92
|
+
# Send our remote request to the Moxi Works Platform
|
93
|
+
#
|
94
|
+
# @param [String] method The HTTP method to be used when connecting; ex: :put, :post, :get
|
95
|
+
# @param [Hash] opts
|
96
|
+
# @option opts [String] :moxi_works_agent_id *REQUIRED* The Moxi Works Agent ID for the agent to which this ActionLog entry is associated
|
97
|
+
# @option opts [String] :partner_contact_id *REQUIRED* Your system's unique ID for the contact for whom the ActionLog entry is being created.
|
98
|
+
# @option opts [String] :title *REQUIRED* A brief title for this ActionLog entry (85 characters or less)
|
99
|
+
# @option opts [String] :body *REQUIRED* The body of this ActionLog entry (255 characters or less)
|
100
|
+
#
|
101
|
+
#
|
102
|
+
# @return [MoxiworksPlatform::ActionLog]
|
103
|
+
#
|
104
|
+
# @raise ::MoxiworksPlatform::Exception::ArgumentError if required
|
105
|
+
# named parameters aren't included
|
106
|
+
#
|
107
|
+
def self.send_request(method, opts={}, url=nil)
|
108
|
+
url ||= "#{MoxiworksPlatform::Config.url}/api/action_logs"
|
109
|
+
required_opts = [:moxi_works_agent_id, :partner_contact_id, :title, :body]
|
110
|
+
required_opts.each do |opt|
|
111
|
+
raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if
|
112
|
+
opts[opt].nil? or opts[opt].empty?
|
113
|
+
end
|
114
|
+
super(method, opts, url)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module MoxiworksPlatform
|
2
|
-
# = Moxi Works Platform
|
2
|
+
# = Moxi Works Platform Group
|
3
3
|
class Group < MoxiworksPlatform::Resource
|
4
4
|
# @!attribute moxi_works_agent_id
|
5
5
|
# moxi_works_agent_id is the Moxi Works Platform ID of the agent which the group is
|
@@ -11,7 +11,7 @@ module MoxiworksPlatform
|
|
11
11
|
attr_accessor :moxi_works_agent_id
|
12
12
|
|
13
13
|
# @!attribute moxi_works_group_id
|
14
|
-
# your system's
|
14
|
+
# your system's group ID for the group
|
15
15
|
#
|
16
16
|
# @return [String] representing the name of the group on the Moxi Works Platform
|
17
17
|
attr_accessor :moxi_works_group_name
|
@@ -22,9 +22,9 @@ module MoxiworksPlatform
|
|
22
22
|
# @return [Array] of MoxiworksPlatform::Contact objects
|
23
23
|
attr_reader :contacts
|
24
24
|
|
25
|
-
# Find
|
25
|
+
# Find a Group your system has previously created in Moxi Works Platform
|
26
26
|
# @param [Hash] opts named parameter Hash
|
27
|
-
# @option opts [String] :moxi_works_agent_id *REQUIRED* The Moxi Works Agent ID for the agent to which this
|
27
|
+
# @option opts [String] :moxi_works_agent_id *REQUIRED* The Moxi Works Agent ID for the agent to which this group is associated
|
28
28
|
# @option opts [Integer] :moxi_works_group_id *REQUIRED* The Moxi Works Group ID for this group.
|
29
29
|
#
|
30
30
|
# @return [MoxiworksPlatform::Group]
|
@@ -43,12 +43,19 @@ module MoxiworksPlatform
|
|
43
43
|
#
|
44
44
|
def self.find(opts={})
|
45
45
|
url = "#{MoxiworksPlatform::Config.url}/api/groups/#{opts[:moxi_works_group_name]}"
|
46
|
-
|
46
|
+
contacts = []
|
47
|
+
response = self.send_request(:get, opts, url)
|
48
|
+
|
49
|
+
response.contacts.each do |c|
|
50
|
+
contacts << MoxiworksPlatform::Contact.new(c) unless c.nil? or c.empty?
|
51
|
+
end
|
52
|
+
response.contacts = contacts
|
53
|
+
response
|
47
54
|
end
|
48
55
|
|
49
56
|
# Search an Agent's Groups in Moxi Works Platform
|
50
57
|
# @param [Hash] opts named parameter Hash
|
51
|
-
# @option opts [String] :moxi_works_agent_id *REQUIRED* The Moxi Works Agent ID for the agent to which this
|
58
|
+
# @option opts [String] :moxi_works_agent_id *REQUIRED* The Moxi Works Agent ID for the agent to which this group is associated
|
52
59
|
# @option opts [String] :name optional name to search for. If no name is provided, all of the Agent's Groups will be returned
|
53
60
|
#
|
54
61
|
# @return [Array] containing MoxiworksPlatform::Group objects formatted as follows:
|
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.
|
4
|
+
version: 0.5.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-
|
11
|
+
date: 2016-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- bin/console
|
84
84
|
- bin/setup
|
85
85
|
- lib/moxiworks_platform.rb
|
86
|
+
- lib/moxiworks_platform/action_log.rb
|
86
87
|
- lib/moxiworks_platform/agent.rb
|
87
88
|
- lib/moxiworks_platform/config.rb
|
88
89
|
- lib/moxiworks_platform/contact.rb
|