moxiworks_platform 0.1.1 → 0.2.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/agent.rb +89 -0
- data/lib/moxiworks_platform/contact.rb +4 -14
- data/lib/moxiworks_platform/resource.rb +26 -0
- 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: 32404d8f1d742f39d698b13b966b4e6a525ce384
|
4
|
+
data.tar.gz: 5b2814778679c1a238d97e1bdf2f0703086a3b7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0779ade05d1df3da5ffa77d749d94a6561a0a2a6ebf72460207a766dbd767c757e745497394390233d743a2244fbe13a535b2b19d2d5d6773f2051afb53da8ac
|
7
|
+
data.tar.gz: a23ad782dc32483bf36eb8a35920bd667429f12e506ad5d73846090869c278541b4b06a71a974028d5a6be29562400bd7478557bc6903f1a36c7e37da9916810
|
data/lib/moxiworks_platform.rb
CHANGED
@@ -0,0 +1,89 @@
|
|
1
|
+
module MoxiworksPlatform
|
2
|
+
# = Moxi Works Platform Agent
|
3
|
+
class Agent < MoxiworksPlatform::Resource
|
4
|
+
|
5
|
+
attr_accessor :moxi_works_agent_id
|
6
|
+
|
7
|
+
attr_accessor :mls
|
8
|
+
|
9
|
+
attr_accessor :accreditation
|
10
|
+
|
11
|
+
attr_accessor :address_street
|
12
|
+
|
13
|
+
attr_accessor :address_city
|
14
|
+
|
15
|
+
attr_accessor :address_state
|
16
|
+
|
17
|
+
attr_accessor :address_zip
|
18
|
+
|
19
|
+
attr_accessor :office_address_street
|
20
|
+
|
21
|
+
attr_accessor :office_address_city
|
22
|
+
|
23
|
+
attr_accessor :office_address_state
|
24
|
+
|
25
|
+
attr_accessor :office_address_zip
|
26
|
+
|
27
|
+
attr_accessor :name
|
28
|
+
|
29
|
+
attr_accessor :license
|
30
|
+
|
31
|
+
attr_accessor :mobile_phone_number
|
32
|
+
|
33
|
+
attr_accessor :home_phone_number
|
34
|
+
|
35
|
+
attr_accessor :fax_phone_number
|
36
|
+
|
37
|
+
attr_accessor :main_phone_number
|
38
|
+
|
39
|
+
attr_accessor :primary_email_address
|
40
|
+
|
41
|
+
attr_accessor :secondary_email_address
|
42
|
+
|
43
|
+
attr_accessor :languages
|
44
|
+
|
45
|
+
attr_accessor :twitter
|
46
|
+
|
47
|
+
attr_accessor :google_plus
|
48
|
+
|
49
|
+
attr_accessor :facebook
|
50
|
+
|
51
|
+
attr_accessor :home_page
|
52
|
+
|
53
|
+
attr_accessor :birth_date
|
54
|
+
|
55
|
+
attr_accessor :title
|
56
|
+
|
57
|
+
attr_accessor :profile_image_url
|
58
|
+
|
59
|
+
attr_accessor :profile_thumb_url
|
60
|
+
|
61
|
+
# Find an Agent on the Moxi Works Platform
|
62
|
+
# @param [Hash] opts named parameter Hash
|
63
|
+
# @option opts [String] :moxi_works_agent_id *REQUIRED* The Moxi Works Agent ID for the agent to which this contact is to be associated
|
64
|
+
#
|
65
|
+
# @return [MoxiworksPlatform::Contact]
|
66
|
+
#
|
67
|
+
# @raise ::MoxiworksPlatform::Exception::ArgumentError if required
|
68
|
+
# named parameters aren't included
|
69
|
+
#
|
70
|
+
def self.find(opts={})
|
71
|
+
url = "#{MoxiworksPlatform::Config.url}/api/agents/#{self.safe_id(opts[:moxi_works_agent_id])}"
|
72
|
+
self.send_request(:get, opts, url)
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.send_request(method, opts={}, url=nil)
|
76
|
+
url ||= "#{MoxiworksPlatform::Config.url}/api/agents"
|
77
|
+
required_opts = [:moxi_works_agent_id]
|
78
|
+
required_opts.each do |opt|
|
79
|
+
raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if
|
80
|
+
opts[opt].nil? or opts[opt].empty?
|
81
|
+
end
|
82
|
+
super(method, opts, url)
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
end
|
@@ -434,7 +434,7 @@ module MoxiworksPlatform
|
|
434
434
|
# named parameters aren't included
|
435
435
|
#
|
436
436
|
def self.find(opts={})
|
437
|
-
url = "#{MoxiworksPlatform::Config.url}/api/contacts/#{opts[:partner_contact_id]}"
|
437
|
+
url = "#{MoxiworksPlatform::Config.url}/api/contacts/#{self.safe_id(opts[:partner_contact_id])}"
|
438
438
|
self.send_request(:get, opts, url)
|
439
439
|
end
|
440
440
|
|
@@ -566,7 +566,7 @@ module MoxiworksPlatform
|
|
566
566
|
#
|
567
567
|
def self.update(opts={})
|
568
568
|
opts[:contact_id] = opts[:partner_contact_id]
|
569
|
-
url = "#{MoxiworksPlatform::Config.url}/api/contacts/#{opts[:partner_contact_id]}"
|
569
|
+
url = "#{MoxiworksPlatform::Config.url}/api/contacts/#{self.safe_id(opts[:partner_contact_id])}"
|
570
570
|
self.send_request(:put, opts, url)
|
571
571
|
end
|
572
572
|
|
@@ -587,7 +587,7 @@ module MoxiworksPlatform
|
|
587
587
|
# success = MoxiWorksPlatform::Contact.delete(moxi_works_agent_id: '123abcd', partner_contact_id: 'myUniqueContactId' )
|
588
588
|
#
|
589
589
|
def self.delete(opts={})
|
590
|
-
url = "#{MoxiworksPlatform::Config.url}/api/contacts/#{opts[:partner_contact_id]}"
|
590
|
+
url = "#{MoxiworksPlatform::Config.url}/api/contacts/#{self.safe_id(opts[:partner_contact_id])}"
|
591
591
|
required_opts = [:moxi_works_agent_id, :partner_contact_id]
|
592
592
|
required_opts.each do |opt|
|
593
593
|
raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if
|
@@ -673,17 +673,7 @@ module MoxiworksPlatform
|
|
673
673
|
opts[opt].nil? or opts[opt].empty?
|
674
674
|
end
|
675
675
|
opts[:contact_id] = opts[:partner_contact_id]
|
676
|
-
|
677
|
-
RestClient::Request.execute(method: method,
|
678
|
-
url: url,
|
679
|
-
payload: opts, headers: self.headers) do |response|
|
680
|
-
puts response if MoxiworksPlatform::Config.debug
|
681
|
-
self.check_for_error_in_response(response)
|
682
|
-
json = JSON.parse(response)
|
683
|
-
return false if not json['status'].nil? and json['status'] =='fail'
|
684
|
-
contact = MoxiworksPlatform::Contact.new(json) unless json.nil? or json.empty?
|
685
|
-
end
|
686
|
-
contact
|
676
|
+
super(method, opts, url)
|
687
677
|
end
|
688
678
|
|
689
679
|
# Save an instance of MoxiWorksPlatform::Contact to Moxi Works Platform
|
@@ -74,6 +74,20 @@ module MoxiworksPlatform
|
|
74
74
|
not json['status'].nil? and (%w(error fail).include?(json['status']))
|
75
75
|
end
|
76
76
|
|
77
|
+
# modify an external ID so that it's fetchable via URL.
|
78
|
+
#
|
79
|
+
# IDs that contain things like dots cause problems when attempting to fetch resources
|
80
|
+
# that use those IDs as primary keys when fetching via RESTful routes
|
81
|
+
# this method converts stuff that isn't handled well, ensuring that we have a uniform
|
82
|
+
# ID and ensuring that those IDs are usable via URL.
|
83
|
+
#
|
84
|
+
# @param [String] an ID to be converted into a URL ready ID
|
85
|
+
#
|
86
|
+
# @return [String] the ID with all the bad stuff converted into URL ready stuff
|
87
|
+
def self.safe_id(id)
|
88
|
+
Base64.urlsafe_encode64(id)
|
89
|
+
end
|
90
|
+
|
77
91
|
# maps Hash values to Instance variables for mapping JSON object values to our Class attributes
|
78
92
|
#
|
79
93
|
def initialize(hash={})
|
@@ -98,6 +112,18 @@ module MoxiworksPlatform
|
|
98
112
|
hash
|
99
113
|
end
|
100
114
|
|
115
|
+
def self.send_request(method, opts={}, url=nil)
|
116
|
+
RestClient::Request.execute(method: method,
|
117
|
+
url: url,
|
118
|
+
payload: opts, headers: self.headers) do |response|
|
119
|
+
puts response if MoxiworksPlatform::Config.debug
|
120
|
+
self.check_for_error_in_response(response)
|
121
|
+
json = JSON.parse(response)
|
122
|
+
return false if not json['status'].nil? and json['status'] =='fail'
|
123
|
+
self.new(json) unless json.nil? or json.empty?
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
101
127
|
end
|
102
128
|
|
103
129
|
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.
|
4
|
+
version: 0.2.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-04-
|
11
|
+
date: 2016-04-30 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/agent.rb
|
86
87
|
- lib/moxiworks_platform/config.rb
|
87
88
|
- lib/moxiworks_platform/contact.rb
|
88
89
|
- lib/moxiworks_platform/credentials.rb
|