moxiworks_platform 0.0.1
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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +38 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/moxiworks_platform.rb +12 -0
- data/lib/moxiworks_platform/config.rb +39 -0
- data/lib/moxiworks_platform/contact.rb +685 -0
- data/lib/moxiworks_platform/credentials.rb +108 -0
- data/lib/moxiworks_platform/exception.rb +10 -0
- data/lib/moxiworks_platform/resource.rb +89 -0
- data/lib/moxiworks_platform/version.rb +3 -0
- data/moxiworks_platform.gemspec +26 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 475dc2ec6d0129c5c8b8bf0ac055deaf0322d5e1
|
4
|
+
data.tar.gz: 2e45e81432029a487bce5ca73145df7b16b54113
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9ddb57edd8cd6f0c68f3f38aef503b118ce2470167f94f6f1930875db8c769f21e959a6f2a25bb9532d18ea756a9ed06a766eec3a8deefe5f902ba610461364f
|
7
|
+
data.tar.gz: 16a8f1f862e5c7632bdf9f632d5695cdfdf601fb44fab0339bfb4263ad91c37813f3e8c9a51d99ae29aed3329fd90907fffc7ebb3e3687ba72d9c1af23b3ee4c
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# MoxiworksPlatform
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'moxiworks_platform'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install moxiworks_platform
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
platform_identifier = 'abc1234'
|
23
|
+
platform_secret = 'secretkey'
|
24
|
+
require 'moxiworks_platform'
|
25
|
+
MoxiworksPlatform::Credentials.new(platform_identifier, platform_secret)
|
26
|
+
contact = MoxiworksPlatform::Contact.create(moxi_works_agent_id: '123abcd', partner_contact_id: 'my_unique_id')
|
27
|
+
```
|
28
|
+
|
29
|
+
## Development
|
30
|
+
|
31
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
32
|
+
|
33
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/moxiworks_platform.
|
38
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "moxiworks_platform"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'moxiworks_platform/version'
|
2
|
+
require 'moxiworks_platform/config'
|
3
|
+
require 'moxiworks_platform/exception'
|
4
|
+
require 'moxiworks_platform/resource'
|
5
|
+
require 'moxiworks_platform/credentials'
|
6
|
+
require 'moxiworks_platform/contact'
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
module MoxiworksPlatform
|
11
|
+
# Your code goes here...
|
12
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module MoxiworksPlatform
|
2
|
+
# moxiworks_platform SDK configurable attributes
|
3
|
+
#
|
4
|
+
# adjustment of these should not be required unless you are debugging an issue
|
5
|
+
# or are using an alternate configuration for connecting to Moxi Works Platform
|
6
|
+
class Config
|
7
|
+
|
8
|
+
class << self
|
9
|
+
|
10
|
+
# @!attribute url
|
11
|
+
#
|
12
|
+
# The Moxi Works Platform base URL. default is 'https://api.moxiworks.com'
|
13
|
+
#
|
14
|
+
# Modification of this attribute should not be needed unless you are debugging or developing for Moxi Works Platform Ruby SDK
|
15
|
+
#
|
16
|
+
# @return [String]
|
17
|
+
attr_accessor :url
|
18
|
+
|
19
|
+
# @!attribute debug
|
20
|
+
#
|
21
|
+
# whether to print debugging info about Moxi Works Platform requests to the console
|
22
|
+
#
|
23
|
+
# Modification of this attribute should not be needed unless you are debugging or developing for Moxi Works Platform Ruby SDK
|
24
|
+
#
|
25
|
+
# @return [Boolean]
|
26
|
+
attr_accessor :debug
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.url=(url)
|
30
|
+
@@url = url
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.url
|
34
|
+
@@url ||= 'https://api.moxiworks.com'
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,685 @@
|
|
1
|
+
module MoxiworksPlatform
|
2
|
+
# = Moxi Works Platform Contact
|
3
|
+
class Contact < MoxiworksPlatform::Resource
|
4
|
+
|
5
|
+
# @!attribute moxi_works_agent_id
|
6
|
+
# moxi_works_agent_id is the Moxi Works Platform ID of the agent which a contact is
|
7
|
+
# or is to be associated with.
|
8
|
+
#
|
9
|
+
# this must be set for any Moxi Works Platform transaction
|
10
|
+
#
|
11
|
+
# @return [String] the Moxi Works Platform ID of the agent
|
12
|
+
attr_accessor :moxi_works_agent_id
|
13
|
+
|
14
|
+
# @!attribute partner_contact_id
|
15
|
+
# *your system's* unique ID for the Contact
|
16
|
+
#
|
17
|
+
# this must be set for any Moxi Works Platform transaction
|
18
|
+
#
|
19
|
+
# @return [String] your system's unique ID for the contact
|
20
|
+
attr_accessor :partner_contact_id
|
21
|
+
|
22
|
+
|
23
|
+
# @!attribute moxi_works_contact_id
|
24
|
+
# Moxi Works Platform ID for the Contact
|
25
|
+
#
|
26
|
+
# @return [String] Moxi Works Platform ID for the contact
|
27
|
+
attr_accessor :partner_contact_id
|
28
|
+
|
29
|
+
|
30
|
+
# @!attribute business_website
|
31
|
+
# the full URL of the business website to be associated with this Contact
|
32
|
+
#
|
33
|
+
# @return [String]-- Default ''
|
34
|
+
attr_accessor :business_website
|
35
|
+
|
36
|
+
# @!attribute contact_name
|
37
|
+
# the full name of this Contact
|
38
|
+
#
|
39
|
+
# @return [String] -- Default ''
|
40
|
+
attr_accessor :contact_name
|
41
|
+
|
42
|
+
# @!attribute gender
|
43
|
+
# the gender of this Contact. the first initial of either gender type may
|
44
|
+
# be used or the full word 'male' or 'female.'
|
45
|
+
#
|
46
|
+
# @note The single character representation will be used after saving to Moxi Works Platform no matter whether the word or single character representation is passed in.
|
47
|
+
#
|
48
|
+
# @return [String, Enumerated] -- a single character 'm' or 'f' or -- Default ''
|
49
|
+
attr_accessor :gender
|
50
|
+
|
51
|
+
# @!attribute home_street_address
|
52
|
+
# the street address of the residence of this Contact
|
53
|
+
#
|
54
|
+
# @return [String] -- Default ''
|
55
|
+
attr_accessor :home_street_address
|
56
|
+
|
57
|
+
# @!attribute home_city
|
58
|
+
# the city of the residence of this Contact
|
59
|
+
#
|
60
|
+
# @return [String] -- Default ''
|
61
|
+
attr_accessor :home_city
|
62
|
+
|
63
|
+
# @!attribute home_state
|
64
|
+
# the state in which the residence of this Contact is located
|
65
|
+
#
|
66
|
+
# this can either be the state's abbreviation or the full name of the state
|
67
|
+
#
|
68
|
+
# @return [String] -- Default ''
|
69
|
+
attr_accessor :home_state
|
70
|
+
|
71
|
+
# @!attribute home_zip
|
72
|
+
# the zip code of the residence of this Contact
|
73
|
+
#
|
74
|
+
# @return [String] -- Default ''
|
75
|
+
attr_accessor :home_zip
|
76
|
+
|
77
|
+
# @!attribute home_neighborhood
|
78
|
+
# the neighborhood of the residence of this Contact
|
79
|
+
#
|
80
|
+
# @return [String] -- Default ''
|
81
|
+
attr_accessor :home_neighborhood
|
82
|
+
|
83
|
+
# @!attribute home_country
|
84
|
+
# the country of the residence of this Contact
|
85
|
+
#
|
86
|
+
# this can either be the country's abbreviation or the full name of the country
|
87
|
+
#
|
88
|
+
# @return [String] -- Default ''
|
89
|
+
attr_accessor :home_country
|
90
|
+
|
91
|
+
# @!attribute job_title
|
92
|
+
# the specific job title this contact has; ex: 'Senior VP of Operations'
|
93
|
+
#
|
94
|
+
# @return [String] -- Default ''
|
95
|
+
attr_accessor :job_title
|
96
|
+
|
97
|
+
# @!attribute occupation
|
98
|
+
# the general occupation of this contact; ex: 'Software Developer'
|
99
|
+
#
|
100
|
+
# @return [String] -- Default ''
|
101
|
+
attr_accessor :occupation
|
102
|
+
|
103
|
+
# @!attribute partner_agent_id
|
104
|
+
# your system's unique identifier for the agent that this contact will be associated with
|
105
|
+
#
|
106
|
+
# @return [String] -- Default ''
|
107
|
+
attr_accessor :partner_agent_id
|
108
|
+
|
109
|
+
# @!attribute primary_email_address
|
110
|
+
# the email address the contact would want to be contacted via first
|
111
|
+
#
|
112
|
+
# @return [String] -- Default ''
|
113
|
+
attr_accessor :primary_email_address
|
114
|
+
|
115
|
+
# @!attribute primary_phone_number
|
116
|
+
# the phone number the contact would want to be contacted via first
|
117
|
+
#
|
118
|
+
# @return [String] -- Default ''
|
119
|
+
attr_accessor :primary_phone_number
|
120
|
+
|
121
|
+
# @!attribute secondary_email_address
|
122
|
+
# an additional email address the contact would want to be contacted by
|
123
|
+
#
|
124
|
+
# @return [String] -- Default ''
|
125
|
+
attr_accessor :secondary_email_address
|
126
|
+
|
127
|
+
# @!attribute secondary_phone_number
|
128
|
+
# an additional phone number the contact would want to be contacted by
|
129
|
+
#
|
130
|
+
# @return [String] -- Default ''
|
131
|
+
attr_accessor :secondary_phone_number
|
132
|
+
|
133
|
+
# @!attribute property_baths
|
134
|
+
#
|
135
|
+
# the number of bathrooms in the listing the contact has expressed interest in
|
136
|
+
#
|
137
|
+
# Property of Interest (POI) attribute
|
138
|
+
#
|
139
|
+
# @return [Float] -- Default nil
|
140
|
+
attr_writer :property_baths
|
141
|
+
|
142
|
+
# @!attribute property_beds
|
143
|
+
#
|
144
|
+
# the number of bedrooms in the listing the contact has expressed interest in
|
145
|
+
#
|
146
|
+
# Property of Interest (POI) attribute
|
147
|
+
#
|
148
|
+
# @return [Integer] -- Default nil
|
149
|
+
attr_writer :property_beds
|
150
|
+
|
151
|
+
# @!attribute property_city
|
152
|
+
#
|
153
|
+
# the city in which the listing the contact has expressed interest in is located
|
154
|
+
#
|
155
|
+
# Property of Interest (POI) attribute
|
156
|
+
#
|
157
|
+
# @return [String] -- Default ''
|
158
|
+
attr_accessor :property_city
|
159
|
+
|
160
|
+
# @!attribute property_list_price
|
161
|
+
#
|
162
|
+
# the list_price of the property the contact has expressed interest in
|
163
|
+
#
|
164
|
+
# Property of Interest (POI) attribute
|
165
|
+
#
|
166
|
+
# @return [Integer] -- Default nil
|
167
|
+
attr_writer :property_list_price
|
168
|
+
|
169
|
+
# @!attribute property_listing_status
|
170
|
+
#
|
171
|
+
# Property of Interest (POI) attribute
|
172
|
+
#
|
173
|
+
# the status of the listing of the Property of Interest; ex: 'Active' or 'Sold'
|
174
|
+
#
|
175
|
+
# @return [String] -- Default ''
|
176
|
+
attr_accessor :property_listing_status
|
177
|
+
|
178
|
+
# @!attribute property_mls_id
|
179
|
+
#
|
180
|
+
# the MLS ID of the listing that of the Property of Interest
|
181
|
+
#
|
182
|
+
# Property of Interest (POI) attribute
|
183
|
+
#
|
184
|
+
# @return [String] -- Default ''
|
185
|
+
attr_accessor :property_mls_id
|
186
|
+
|
187
|
+
# @!attribute property_photo_url
|
188
|
+
#
|
189
|
+
# a full URL to a photo of the Property of Interest
|
190
|
+
#
|
191
|
+
# Property of Interest (POI) attribute
|
192
|
+
#
|
193
|
+
# @return [String] -- Default ''
|
194
|
+
attr_accessor :property_photo_url
|
195
|
+
|
196
|
+
# @!attribute property_state
|
197
|
+
#
|
198
|
+
# the state in which the listing the contact has expressed interest in is located
|
199
|
+
#
|
200
|
+
# Property of Interest (POI) attribute
|
201
|
+
#
|
202
|
+
# @return [String] -- Default ''
|
203
|
+
attr_accessor :property_state
|
204
|
+
|
205
|
+
# @!attribute property_street_address
|
206
|
+
#
|
207
|
+
# the street address of the listing the contact has expressed interest in is located
|
208
|
+
#
|
209
|
+
# Property of Interest (POI) attribute
|
210
|
+
#
|
211
|
+
# @return [String] -- Default ''
|
212
|
+
attr_accessor :property_street_address
|
213
|
+
|
214
|
+
# @!attribute property_url
|
215
|
+
#
|
216
|
+
# a URL referencing a HTTP(S) location which has information about the listing
|
217
|
+
#
|
218
|
+
# Property of Interest (POI) attribute
|
219
|
+
#
|
220
|
+
# @return [String] -- Default ''
|
221
|
+
attr_accessor :property_url
|
222
|
+
|
223
|
+
# @!attribute property_zip
|
224
|
+
#
|
225
|
+
# the zip code in which the listing the contact has expressed interest in is located
|
226
|
+
#
|
227
|
+
# Property of Interest (POI) attribute
|
228
|
+
#
|
229
|
+
# @return [String] -- Default ''
|
230
|
+
attr_accessor :property_zip
|
231
|
+
|
232
|
+
# @!attribute search_city
|
233
|
+
#
|
234
|
+
# the city which the contact has searched for listings in
|
235
|
+
#
|
236
|
+
# Property Search (PS) attribute
|
237
|
+
#
|
238
|
+
# @return [String] -- Default ''
|
239
|
+
attr_accessor :search_city
|
240
|
+
|
241
|
+
# @!attribute search_state
|
242
|
+
#
|
243
|
+
# the state which the contact has searched for listings in
|
244
|
+
#
|
245
|
+
# Property Search (PS) attribute
|
246
|
+
#
|
247
|
+
# @return [String] -- Default ''
|
248
|
+
attr_accessor :search_state
|
249
|
+
|
250
|
+
# @!attribute search_zip
|
251
|
+
#
|
252
|
+
# the zip code which the contact has searched for listings in
|
253
|
+
#
|
254
|
+
# Property Search (PS) attribute
|
255
|
+
#
|
256
|
+
# @return [String] -- Default ''
|
257
|
+
attr_accessor :search_zip
|
258
|
+
|
259
|
+
# @!attribute search_max_lot_size
|
260
|
+
#
|
261
|
+
# the maximum lot size used by the contact when searching for listings
|
262
|
+
#
|
263
|
+
# Property Search (PS) attribute
|
264
|
+
#
|
265
|
+
# @return [Integer] -- Default nil
|
266
|
+
attr_writer :search_max_lot_size
|
267
|
+
|
268
|
+
# @!attribute search_max_price
|
269
|
+
#
|
270
|
+
# the maximum price value used by the contact when searching for listings
|
271
|
+
#
|
272
|
+
# Property Search (PS) attribute
|
273
|
+
#
|
274
|
+
# @return [Integer] -- Default nil
|
275
|
+
attr_writer :search_max_price
|
276
|
+
|
277
|
+
# @!attribute search_max_sq_ft
|
278
|
+
#
|
279
|
+
# the maximum listing square footage used by the contact when searching for listings
|
280
|
+
#
|
281
|
+
# Property Search (PS) attribute
|
282
|
+
#
|
283
|
+
# @return [Integer] -- Default nil
|
284
|
+
attr_writer :search_max_sq_ft
|
285
|
+
|
286
|
+
# @!attribute search_max_year_built
|
287
|
+
#
|
288
|
+
# the maximum year built used by the contact when searching for listings
|
289
|
+
#
|
290
|
+
# Property Search (PS) attribute
|
291
|
+
#
|
292
|
+
# @return [Integer] -- Default nil
|
293
|
+
attr_writer :search_max_year_built
|
294
|
+
|
295
|
+
# @!attribute search_min_baths
|
296
|
+
#
|
297
|
+
# Property Search (PS) attribute
|
298
|
+
#
|
299
|
+
# the minimum number of bathrooms used by the contact when searching for listings
|
300
|
+
#
|
301
|
+
# @return [Float] -- Default nil
|
302
|
+
attr_writer :search_min_baths
|
303
|
+
|
304
|
+
# @!attribute search_min_beds
|
305
|
+
#
|
306
|
+
# the minimum number of bedrooms used by the contact when searching for listings
|
307
|
+
#
|
308
|
+
# Property Search (PS) attribute
|
309
|
+
#
|
310
|
+
# @return [Integer] -- Default nil
|
311
|
+
attr_writer :search_min_beds
|
312
|
+
|
313
|
+
# @!attribute search_min_price
|
314
|
+
#
|
315
|
+
# the minimum price used by the contact when searching for listings
|
316
|
+
#
|
317
|
+
# Property Search (PS) attribute
|
318
|
+
#
|
319
|
+
# @return [Integer] -- Default nil
|
320
|
+
attr_writer :search_min_price
|
321
|
+
|
322
|
+
# @!attribute search_min_sq_ft
|
323
|
+
#
|
324
|
+
# the minimum square footage used by the contact when searching for listings
|
325
|
+
#
|
326
|
+
# Property Search (PS) attribute
|
327
|
+
#
|
328
|
+
# @return [Integer] -- Default nil
|
329
|
+
attr_writer :search_min_sq_ft
|
330
|
+
|
331
|
+
# @!attribute search_min_year_built
|
332
|
+
#
|
333
|
+
# the minimum year built used by the contact when searching for listings
|
334
|
+
#
|
335
|
+
# Property Search (PS) attribute
|
336
|
+
#
|
337
|
+
# @return [Integer] -- Default nil
|
338
|
+
attr_writer :search_min_year_built
|
339
|
+
|
340
|
+
# @!attribute search_property_types
|
341
|
+
#
|
342
|
+
# the property types used by the contact when searching for listings; ex: 'Condo' 'Single-Family' 'Townhouse'
|
343
|
+
#
|
344
|
+
# Property Search (PS) attribute
|
345
|
+
#
|
346
|
+
# @return [String] -- Default nil
|
347
|
+
attr_accessor :search_property_types
|
348
|
+
|
349
|
+
# Creates a new Contact in Moxi Works Platform
|
350
|
+
# @param [Hash] opts named parameter Hash
|
351
|
+
# @option opts [String] :moxi_works_agent_id *REQUIRED* The Moxi Works Agent ID for the agent to which this contact is to be associated
|
352
|
+
# @option opts [String] :partner_contact_id *REQUIRED* Your system's unique ID for this contact.
|
353
|
+
#
|
354
|
+
# optional Contact parameters
|
355
|
+
#
|
356
|
+
# @option opts [String] :business_website full url of a website associated with this contact
|
357
|
+
# @option opts [String] :contact_name full name of this contact in format "Firstname Middlename Lastname"
|
358
|
+
# @option opts [String, Enumerated] :gender can be "male" or "female" or "m" or "f"
|
359
|
+
# @option opts [String] :home_street_address the street address and street on which the contact lives
|
360
|
+
# @option opts [String] :home_city city or township in which this contact lives
|
361
|
+
# @option opts [String] :home_state state in which this contact lives; can be abbreviation or full name
|
362
|
+
# @option opts [String] :home_zip zip code in which this contact lives
|
363
|
+
# @option opts [String] :home_neighborhood neighborhood in which this contact lives
|
364
|
+
# @option opts [String] :home_country country in which this contact lives; can be abbreviation or full name
|
365
|
+
# @option opts [String] :job_title the specific job title this contact has; ex: 'Senior VP of Operations'
|
366
|
+
# @option opts [String] :occupation the general occupation of this contact; ex: 'Software Developer'
|
367
|
+
# @option opts [String] :partner_agent_id your system's unique ID for the agent this contact is to be associated with
|
368
|
+
# @option opts [String] :primary_email_address the primary email address for this contact
|
369
|
+
# @option opts [String] :primary_phone_number the primary phone number for this contact
|
370
|
+
# @option opts [String] :secondary_email_address the secondary email address for this contact
|
371
|
+
# @option opts [String] :secondary_phone_number the secondary phone number for this contact
|
372
|
+
#
|
373
|
+
# optional Property of Interest (POI) parameters:
|
374
|
+
# The POI is a property that the contact has shown interest in.
|
375
|
+
#
|
376
|
+
# @option opts [Float] :property_baths the number of baths in the Property of Interest
|
377
|
+
# @option opts [Integer] :property_beds the number of bedrooms in the Property of Interest
|
378
|
+
# @option opts [String] :property_city the city in which the Property of Interest is located
|
379
|
+
# @option opts [Integer] :property_list_price the list price of the Property of Interest
|
380
|
+
# @option opts [String] :property_listing_status the status of the Property of Interest; ex: 'Active' or 'Sold'
|
381
|
+
# @option opts [String] :property_mls_id the MLS ID of the listing
|
382
|
+
# @option opts [String] :property_photo_url a full URL of an image of the Property of Interest
|
383
|
+
# @option opts [String] :property_state the state which the Property of Interest is in
|
384
|
+
# @option opts [String] :property_street_address the street address that the Property of Interest is on
|
385
|
+
# @option opts [String] :property_url a URL to a page with more information about the Property of Interest
|
386
|
+
# @option opts [String] :property_zip the zip code which the Property of Interest is in
|
387
|
+
#
|
388
|
+
# optional Search Reference parameters:
|
389
|
+
# The Search Reference parameters reflect search criteria that the contact
|
390
|
+
# has used while searching for a listing
|
391
|
+
#
|
392
|
+
# @option opts [String] :search_city the city or locality which this contact has searched for a listing
|
393
|
+
# @option opts [String] :search_state the state in which this contact has searched for a listing
|
394
|
+
# @option opts [String] :search_zip the zip code or postal code in which this contact has searched for a listing
|
395
|
+
# @option opts [Integer] :search_max_lot_size the maximum lot size that this contact has used as criteria when searching for a listing
|
396
|
+
# @option opts [Integer] :search_max_price the maximum price that this contact has used as criteria when searching for a listing
|
397
|
+
# @option opts [Integer] :search_max_sq_ft the maximum square feet that this contact has used as criteria when searching for a listing
|
398
|
+
# @option opts [Integer] :search_max_year_built the maximum year built this contact has used as criteria when searching for a listing
|
399
|
+
# @option opts [Float] :search_min_baths the minimum number of baths this contact has used as criteria when searching for a listing
|
400
|
+
# @option opts [Integer] :search_min_beds the minimum number of bedrooms this contact has used as criteria when searching for a listing
|
401
|
+
# @option opts [Integer] :search_min_lot_size the minimum lot size this contact has used as criteria when searching for a listing
|
402
|
+
# @option opts [Integer] :search_min_price the minimum price this contact has used as criteria when searching for a listing
|
403
|
+
# @option opts [Integer] :search_min_sq_ft the minimum number of square feet this contact has used as criteria when searching for a listing
|
404
|
+
# @option opts [Integer] :search_min_year_built the minimum year built this contact has used as criteria when searching for a listing
|
405
|
+
# @option opts [String] :search_property_types property types this contact has searched for; ex: 'Single Family, Condo, Townhouse'
|
406
|
+
#
|
407
|
+
# @example
|
408
|
+
# MoxiworksPlatform::Contact.create(
|
409
|
+
# moxi_works_agent_id: '123abc',
|
410
|
+
# partner_contact_id: '1234',
|
411
|
+
# contact_name: 'george p warshington',
|
412
|
+
# home_street: '123 this way',
|
413
|
+
# home_city: 'cittyvile',
|
414
|
+
# home_state: 'HI',
|
415
|
+
# home_country: 'USA',
|
416
|
+
# home_neighborhood: 'my hood',
|
417
|
+
# job_title: 'junior bacon burner',
|
418
|
+
# occupation: 'chef',
|
419
|
+
# business_website: 'http://bear.wrass.ler',
|
420
|
+
# primary_email_address: 'goo@goo.goo',
|
421
|
+
# primary_phone_number: '123213',
|
422
|
+
# property_mls_id: '1232312abcv',
|
423
|
+
# secondary_phone_number: '1234567890')
|
424
|
+
# @return [MoxiworksPlatform::Contact]
|
425
|
+
def self.create(opts={})
|
426
|
+
self.send_request(:post, opts)
|
427
|
+
end
|
428
|
+
|
429
|
+
# Find a Contact your system has previously created in Moxi Works Platform
|
430
|
+
# @param [Hash] opts named parameter Hash
|
431
|
+
# @option opts [String] :moxi_works_agent_id *REQUIRED* The Moxi Works Agent ID for the agent to which this contact is to be associated
|
432
|
+
# @option opts [String] :partner_contact_id *REQUIRED* Your system's unique ID for this contact.
|
433
|
+
#
|
434
|
+
# returns [MoxiworksPlatform::Contact]
|
435
|
+
def self.find(opts={})
|
436
|
+
self.send_request(:get, opts)
|
437
|
+
end
|
438
|
+
|
439
|
+
# Updates a previously created Contact in Moxi Works Platform
|
440
|
+
# @param [Hash] opts
|
441
|
+
# @option opts [String] :moxi_works_agent_id *REQUIRED* The Moxi Works Agent ID for the agent to which this contact is to be associated
|
442
|
+
# @option opts [String] :partner_contact_id *REQUIRED* Your system's unique ID for this contact.
|
443
|
+
#
|
444
|
+
# optional Contact parameters
|
445
|
+
#
|
446
|
+
# @option opts [String] :moxi_works_contact_id Moxi Works Platform contact ID
|
447
|
+
# @option opts [String] :business_website full url of a website associated with this contact
|
448
|
+
# @option opts [String] :contact_name full name of this contact in format "Firstname Middlename Lastname"
|
449
|
+
# @option opts [String, Enumerated] :gender can be "male" or "female" or "m" or "f"
|
450
|
+
# @option opts [String] :home_street_address the street address and street on which the contact lives
|
451
|
+
# @option opts [String] :home_city city or township in which this contact lives
|
452
|
+
# @option opts [String] :home_state state in which this contact lives; can be abbreviation or full name
|
453
|
+
# @option opts [String] :home_zip zip code in which this contact lives
|
454
|
+
# @option opts [String] :home_neighborhood neighborhood in which this contact lives
|
455
|
+
# @option opts [String] :home_country country in which this contact lives; can be abbreviation or full name
|
456
|
+
# @option opts [String] :job_title the specific job title this contact has; ex: 'Senior VP of Operations'
|
457
|
+
# @option opts [String] :occupation the general occupation of this contact; ex: 'Software Developer'
|
458
|
+
# @option opts [String] :partner_agent_id your system's unique ID for the agent this contact is to be associated with
|
459
|
+
# @option opts [String] :primary_email_address the primary email address for this contact
|
460
|
+
# @option opts [String] :primary_phone_number the primary phone number for this contact
|
461
|
+
# @option opts [String] :secondary_email_address the secondary email address for this contact
|
462
|
+
# @option opts [String] :secondary_phone_number the secondary phone number for this contact
|
463
|
+
#
|
464
|
+
# optional Property of Interest (POI) parameters:
|
465
|
+
# The POI is a property that the contact has shown interest in.
|
466
|
+
#
|
467
|
+
# @option opts [Float] :property_baths the number of baths in the Property of Interest
|
468
|
+
# @option opts [Integer] :property_beds the number of bedrooms in the Property of Interest
|
469
|
+
# @option opts [String] :property_city the city in which the Property of Interest is located
|
470
|
+
# @option opts [Integer] :property_list_price the list price of the Property of Interest
|
471
|
+
# @option opts [String] :property_listing_status the status of the Property of Interest; ex: 'Active' or 'Sold'
|
472
|
+
# @option opts [String] :property_mls_id the MLS ID of the listing
|
473
|
+
# @option opts [String] :property_photo_url a full URL of an image of the Property of Interest
|
474
|
+
# @option opts [String] :property_state the state which the Property of Interest is in
|
475
|
+
# @option opts [String] :property_street_address the street address that the Property of Interest is on
|
476
|
+
# @option opts [String] :property_url a URL to a page with more information about the Property of Interest
|
477
|
+
# @option opts [String] :property_zip the zip code which the Property of Interest is in
|
478
|
+
#
|
479
|
+
# optional Search Reference parameters:
|
480
|
+
# The Search Reference parameters reflect search criteria that the contact
|
481
|
+
# has used while searching for a listing
|
482
|
+
#
|
483
|
+
# @option opts [String] :search_city the city or locality which this contact has searched for a listing
|
484
|
+
# @option opts [String] :search_state the state in which this contact has searched for a listing
|
485
|
+
# @option opts [String] :search_zip the zip code or postal code in which this contact has searched for a listing
|
486
|
+
# @option opts [Integer] :search_max_lot_size the maximum lot size that this contact has used as criteria when searching for a listing
|
487
|
+
# @option opts [Integer] :search_max_price the maximum price that this contact has used as criteria when searching for a listing
|
488
|
+
# @option opts [Integer] :search_max_sq_ft the maximum square feet that this contact has used as criteria when searching for a listing
|
489
|
+
# @option opts [Integer] :search_max_year_built the maximum year built this contact has used as criteria when searching for a listing
|
490
|
+
# @option opts [Float] :search_min_baths the minimum number of baths this contact has used as criteria when searching for a listing
|
491
|
+
# @option opts [Integer] :search_min_beds the minimum number of bedrooms this contact has used as criteria when searching for a listing
|
492
|
+
# @option opts [Integer] :search_min_lot_size the minimum lot size this contact has used as criteria when searching for a listing
|
493
|
+
# @option opts [Integer] :search_min_price the minimum price this contact has used as criteria when searching for a listing
|
494
|
+
# @option opts [Integer] :search_min_sq_ft the minimum number of square feet this contact has used as criteria when searching for a listing
|
495
|
+
# @option opts [Integer] :search_min_year_built the minimum year built this contact has used as criteria when searching for a listing
|
496
|
+
# @option opts [String] :search_property_types property types this contact has searched for; ex: 'Single Family, Condo, Townhouse'
|
497
|
+
#
|
498
|
+
# @return [MoxiworksPlatform::Contact]
|
499
|
+
#
|
500
|
+
# @example
|
501
|
+
# MoxiworksPlatform::Contact.update(
|
502
|
+
# moxi_works_agent_id: '123abc',
|
503
|
+
# partner_contact_id: '1234',
|
504
|
+
# contact_name: 'george p warshington',
|
505
|
+
# home_street: '123 this way',
|
506
|
+
# home_city: 'cittyvile',
|
507
|
+
# home_state: 'HI',
|
508
|
+
# home_country: 'USA',
|
509
|
+
# home_neighborhood: 'my hood',
|
510
|
+
# job_title: 'junior bacon burner',
|
511
|
+
# occupation: 'chef',
|
512
|
+
# business_website: 'http://bear.wrass.ler',
|
513
|
+
# primary_email_address: 'goo@goo.goo',
|
514
|
+
# primary_phone_number: '123213',
|
515
|
+
# property_mls_id: '1232312abcv',
|
516
|
+
# secondary_phone_number: '1234567890')
|
517
|
+
def self.update(opts={})
|
518
|
+
opts[:contact_id] = opts[:partner_contact_id] || opts[:moxi_works_contact_id]
|
519
|
+
url = "#{MoxiworksPlatform::Config.url}/api/contacts/#{opts[:contact_id]}"
|
520
|
+
self.send_request(:put, opts, url)
|
521
|
+
end
|
522
|
+
|
523
|
+
# Delete a Contact your system has previously created in Moxi Works Platform
|
524
|
+
# @param [Hash] opts named parameter Hash
|
525
|
+
#
|
526
|
+
# required parameters
|
527
|
+
#
|
528
|
+
# @option opts [String] :moxi_works_agent_id *REQUIRED* The Moxi Works Agent ID for the agent to which this contact is to be associated
|
529
|
+
# @option opts [String] :partner_contact_id *REQUIRED* Your system's unique ID for this contact.
|
530
|
+
#
|
531
|
+
# @return [Boolean] -- success of the delete action
|
532
|
+
#
|
533
|
+
# @example
|
534
|
+
# success = MoxiWorksPlatform::Contact.delete(moxi_works_agent_id: '123abcd', partner_contact_id: 'myUniqueContactId' )
|
535
|
+
#
|
536
|
+
def self.delete(opts={})
|
537
|
+
self.send_request(:delete, opts)
|
538
|
+
end
|
539
|
+
|
540
|
+
# Send our remote request to the Moxi Works Platform
|
541
|
+
#
|
542
|
+
# @param [String] method The HTTP method to be used when connecting; ex: :put, :post, :get
|
543
|
+
# @param [Hash] opts
|
544
|
+
# @option opts [String] :moxi_works_agent_id *REQUIRED* The Moxi Works Agent ID for the agent to which this contact is to be associated
|
545
|
+
# @option opts [String] :partner_contact_id *REQUIRED* Your system's unique ID for this contact.
|
546
|
+
#
|
547
|
+
# optional Contact parameters
|
548
|
+
#
|
549
|
+
# @option opts [String] :moxi_works_contact_id Moxi Works Platform contact ID
|
550
|
+
# @option opts [String] :business_website full url of a website associated with this contact
|
551
|
+
# @option opts [String] :contact_name full name of this contact in format "Firstname Middlename Lastname"
|
552
|
+
# @option opts [String, Enumerated] :gender can be "male" or "female" or "m" or "f"
|
553
|
+
# @option opts [String] :home_street_address the street address and street on which the contact lives
|
554
|
+
# @option opts [String] :home_city city or township in which this contact lives
|
555
|
+
# @option opts [String] :home_state state in which this contact lives; can be abbreviation or full name
|
556
|
+
# @option opts [String] :home_zip zip code in which this contact lives
|
557
|
+
# @option opts [String] :home_neighborhood neighborhood in which this contact lives
|
558
|
+
# @option opts [String] :home_country country in which this contact lives; can be abbreviation or full name
|
559
|
+
# @option opts [String] :job_title the specific job title this contact has; ex: 'Senior VP of Operations'
|
560
|
+
# @option opts [String] :occupation the general occupation of this contact; ex: 'Software Developer'
|
561
|
+
# @option opts [String] :partner_agent_id your system's unique ID for the agent this contact is to be associated with
|
562
|
+
# @option opts [String] :primary_email_address the primary email address for this contact
|
563
|
+
# @option opts [String] :primary_phone_number the primary phone number for this contact
|
564
|
+
# @option opts [String] :secondary_email_address the secondary email address for this contact
|
565
|
+
# @option opts [String] :secondary_phone_number the secondary phone number for this contact
|
566
|
+
#
|
567
|
+
# optional Property of Interest (POI) parameters:
|
568
|
+
# The POI is a property that the contact has shown interest in.
|
569
|
+
#
|
570
|
+
# @option opts [Float] :property_baths the number of baths in the Property of Interest
|
571
|
+
# @option opts [Integer] :property_beds the number of bedrooms in the Property of Interest
|
572
|
+
# @option opts [String] :property_city the city in which the Property of Interest is located
|
573
|
+
# @option opts [Integer] :property_list_price the list price of the Property of Interest
|
574
|
+
# @option opts [String] :property_listing_status the status of the Property of Interest; ex: 'Active' or 'Sold'
|
575
|
+
# @option opts [String] :property_mls_id the MLS ID of the listing
|
576
|
+
# @option opts [String] :property_photo_url a full URL of an image of the Property of Interest
|
577
|
+
# @option opts [String] :property_state the state which the Property of Interest is in
|
578
|
+
# @option opts [String] :property_street_address the street address that the Property of Interest is on
|
579
|
+
# @option opts [String] :property_url a URL to a page with more information about the Property of Interest
|
580
|
+
# @option opts [String] :property_zip the zip code which the Property of Interest is in
|
581
|
+
#
|
582
|
+
# optional Search Reference parameters:
|
583
|
+
# The Search Reference parameters reflect search criteria that the contact
|
584
|
+
# has used while searching for a listing
|
585
|
+
#
|
586
|
+
# @option opts [String] :search_city the city or locality which this contact has searched for a listing
|
587
|
+
# @option opts [String] :search_state the state in which this contact has searched for a listing
|
588
|
+
# @option opts [String] :search_zip the zip code or postal code in which this contact has searched for a listing
|
589
|
+
# @option opts [Integer] :search_max_lot_size the maximum lot size that this contact has used as criteria when searching for a listing
|
590
|
+
# @option opts [Integer] :search_max_price the maximum price that this contact has used as criteria when searching for a listing
|
591
|
+
# @option opts [Integer] :search_max_sq_ft the maximum square feet that this contact has used as criteria when searching for a listing
|
592
|
+
# @option opts [Integer] :search_max_year_built the maximum year built this contact has used as criteria when searching for a listing
|
593
|
+
# @option opts [Float] :search_min_baths the minimum number of baths this contact has used as criteria when searching for a listing
|
594
|
+
# @option opts [Integer] :search_min_beds the minimum number of bedrooms this contact has used as criteria when searching for a listing
|
595
|
+
# @option opts [Integer] :search_min_lot_size the minimum lot size this contact has used as criteria when searching for a listing
|
596
|
+
# @option opts [Integer] :search_min_price the minimum price this contact has used as criteria when searching for a listing
|
597
|
+
# @option opts [Integer] :search_min_sq_ft the minimum number of square feet this contact has used as criteria when searching for a listing
|
598
|
+
# @option opts [Integer] :search_min_year_built the minimum year built this contact has used as criteria when searching for a listing
|
599
|
+
# @option opts [String] :search_property_types property types this contact has searched for; ex: 'Single Family, Condo, Townhouse'
|
600
|
+
#
|
601
|
+
# @param [String] url The full URLto connect to
|
602
|
+
# @return [MoxiworksPlatform::Contact]
|
603
|
+
def self.send_request(method, opts={}, url=nil)
|
604
|
+
url ||= "#{MoxiworksPlatform::Config.url}/api/contacts"
|
605
|
+
opts[:contact_id] = opts[:partner_contact_id] || opts[:moxi_works_contact_id]
|
606
|
+
required_opts = [:moxi_works_agent_id, :contact_id]
|
607
|
+
required_opts.each do |opt|
|
608
|
+
message = opt == :contact_id ? 'partner_contact_id or moxi_works_contact_id required' : "#{opt} required"
|
609
|
+
raise ::MoxiworksPlatform::Exception::ArgumentError, message if
|
610
|
+
opts[opt].nil? or opts[opt].empty?
|
611
|
+
end
|
612
|
+
contact = nil
|
613
|
+
RestClient::Request.execute(method: method,
|
614
|
+
url: url,
|
615
|
+
payload: opts, headers: self.headers) do |response|
|
616
|
+
puts response if MoxiworksPlatform::Config.debug
|
617
|
+
json = JSON.parse(response)
|
618
|
+
contact = MoxiworksPlatform::Contact.new(json) unless json.nil? or json.empty?
|
619
|
+
end
|
620
|
+
contact
|
621
|
+
end
|
622
|
+
|
623
|
+
# Save an instance of MoxiWorksPlatform::Contact to Moxi Works Platform
|
624
|
+
#
|
625
|
+
# @return [MoxiWorksPlatform::Contact]
|
626
|
+
#
|
627
|
+
# @example
|
628
|
+
# contact = MoxiWorksPlatform::Contact.new()
|
629
|
+
# contact.moxi_works_agent_id = '123abcd'
|
630
|
+
# contact.partner_contact_id = 'myUniqueContactIdentifier'
|
631
|
+
# contact.contact_name = 'J Jonah Jameson'
|
632
|
+
# contact.primary_email_address = 'j.jonah.jameson@househun.ter'
|
633
|
+
# contact.save
|
634
|
+
def save
|
635
|
+
MoxiworksPlatform::Contact.create(self.to_hash)
|
636
|
+
end
|
637
|
+
|
638
|
+
# Delete an instance of MoxiWorksPlatform::Contact from Moxi Works Platform
|
639
|
+
#
|
640
|
+
# @return [Boolean] -- success of the delete action
|
641
|
+
#
|
642
|
+
# @example
|
643
|
+
# contact = MoxiWorksPlatform::Contact.find(moxi_works_agent_id: '123abcd', partner_contact_id: 'myUniqueContactId' )
|
644
|
+
# success = contact.delete
|
645
|
+
def delete(opts={})
|
646
|
+
MoxiworksPlatform::Contact.delete(opts)
|
647
|
+
end
|
648
|
+
|
649
|
+
private
|
650
|
+
def method_missing(meth, *args, &block)
|
651
|
+
float_attrs = [:property_baths, :search_min_baths]
|
652
|
+
int_attrs = [:property_beds, :property_list_price, :search_min_year_built,
|
653
|
+
:search_min_sq_ft, :search_min_price, :search_min_beds,
|
654
|
+
:search_max_year_built, :search_max_sq_ft, :search_max_price,
|
655
|
+
:search_max_lot_size]
|
656
|
+
all_attrs = float_attrs + int_attrs
|
657
|
+
|
658
|
+
name = meth.to_sym
|
659
|
+
if all_attrs.include? name
|
660
|
+
return numeric_value_for(name, type: :integer) if int_attrs.include? name
|
661
|
+
return numeric_value_for(name, type: :float) if float_attrs.include? name
|
662
|
+
end
|
663
|
+
super(meth, *args, &block)
|
664
|
+
end
|
665
|
+
|
666
|
+
def numeric_value_for(attr_name, opts={})
|
667
|
+
val = self.instance_variable_get("@#{attr_name}")
|
668
|
+
return val if val.is_a? Numeric
|
669
|
+
case opts[:type]
|
670
|
+
when :integer
|
671
|
+
instance_variable_set("@#{attr_name}", (val.nil? or val.empty?) ? nil : val.to_i)
|
672
|
+
when :float
|
673
|
+
instance_variable_set("@#{attr_name}", (val.nil? or val.empty?) ? nil : val.to_f)
|
674
|
+
else
|
675
|
+
instance_variable_set("@#{attr_name}", nil)
|
676
|
+
end
|
677
|
+
self.instance_variable_get("@#{attr_name}")
|
678
|
+
rescue => e
|
679
|
+
puts "problem with auto conversion: #{e.message} #{e.backtrace}"
|
680
|
+
nil
|
681
|
+
end
|
682
|
+
|
683
|
+
end
|
684
|
+
|
685
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
module MoxiworksPlatform
|
2
|
+
# = Moxi Works Platform Credentials
|
3
|
+
#
|
4
|
+
# A Singleton class used for authorization on the Moxi Works Platform
|
5
|
+
#
|
6
|
+
class Credentials
|
7
|
+
|
8
|
+
class << self
|
9
|
+
# @!attribute instance
|
10
|
+
#
|
11
|
+
# Singleton instance of MoxiworksPlatform::Credentials
|
12
|
+
#
|
13
|
+
# @return [MoxiworksPlatform::Credentials]
|
14
|
+
attr_accessor :instance
|
15
|
+
|
16
|
+
# @!attribute platform_identifier
|
17
|
+
#
|
18
|
+
# The Moxi Works Platform Identifier associated with the MoxiworksPlatform::Credentials instance
|
19
|
+
#
|
20
|
+
# This should be set when MoxiworksPlafform::Credentials is instantiated
|
21
|
+
#
|
22
|
+
# @return [String]
|
23
|
+
attr_accessor :platform_identifier
|
24
|
+
|
25
|
+
# @!attribute platform_secret
|
26
|
+
#
|
27
|
+
# The Moxi Works Platform Secret associated with the MoxiworksPlatform::Credentials instance
|
28
|
+
#
|
29
|
+
# This should be set when MoxiworksPlafform::Credentials is instantiated
|
30
|
+
#
|
31
|
+
# @return [String]
|
32
|
+
attr_accessor :platform_secret
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
# @param [String] platform_id Your provided Moxi Works Platform Identifier
|
37
|
+
# @param [String] platform_secret Your provided Moxi Works Platform Secret
|
38
|
+
#
|
39
|
+
# @return [MoxiWorksPlatform::Credentials]
|
40
|
+
#
|
41
|
+
# @example
|
42
|
+
# platform_identifier = 'abc1234'
|
43
|
+
# platform_secret = 'secret'
|
44
|
+
# MoxiworksPlatform::Credentials.new(platform_identifier, platform_secret)
|
45
|
+
def self.new(*args, &block)
|
46
|
+
pid = args[0]
|
47
|
+
ps = args[1]
|
48
|
+
return MoxiworksPlatform::Credentials.instance if
|
49
|
+
MoxiworksPlatform::Credentials.instance and
|
50
|
+
(pid == MoxiworksPlatform::Credentials.platform_identifier and
|
51
|
+
ps == MoxiworksPlatform::Credentials.platform_secret)
|
52
|
+
|
53
|
+
super(*args, &block)
|
54
|
+
end
|
55
|
+
|
56
|
+
# whether the required values for authorization have been set in the Singleton instance of MoxiworksPlatform::Credentials
|
57
|
+
#
|
58
|
+
# @return [Boolean] Returns `true` if the access key id and secret access key are both set.
|
59
|
+
def self.set?
|
60
|
+
not ((platform_identifier.nil? or
|
61
|
+
platform_identifier.empty?) or
|
62
|
+
(platform_secret.nil? or
|
63
|
+
platform_secret.empty?))
|
64
|
+
end
|
65
|
+
|
66
|
+
# @param [String] platform_id Your provided Moxi Works Platform Identifier
|
67
|
+
# @param [String] platform_secret Your provided Moxi Works Platform Secret
|
68
|
+
#
|
69
|
+
def initialize(platform_identifier, platform_secret)
|
70
|
+
return if MoxiworksPlatform::Credentials.instance
|
71
|
+
MoxiworksPlatform::Credentials.platform_identifier = platform_identifier
|
72
|
+
MoxiworksPlatform::Credentials.platform_secret = platform_secret
|
73
|
+
MoxiworksPlatform::Credentials.instance = self
|
74
|
+
end
|
75
|
+
|
76
|
+
# The Moxi Works Platform Identifier associated with the MoxiworksPlatform::Credentials instance
|
77
|
+
#
|
78
|
+
# This should be set when MoxiworksPlafform::Credentials is instantiated
|
79
|
+
#
|
80
|
+
# @return [String]
|
81
|
+
def platform_identifier
|
82
|
+
MoxiworksPlatform::Credentials.platform_identifier
|
83
|
+
end
|
84
|
+
|
85
|
+
# The Moxi Works Platform Secret associated with the MoxiworksPlatform::Credentials instance
|
86
|
+
#
|
87
|
+
# This should be set when MoxiworksPlafform::Credentials is instantiated
|
88
|
+
#
|
89
|
+
# @return [String]
|
90
|
+
def platform_secret
|
91
|
+
MoxiworksPlatform::Credentials.platform_secret
|
92
|
+
end
|
93
|
+
|
94
|
+
# whether the required values for authorization have been set in the Singleton instance of MoxiworksPlatform::Credentials
|
95
|
+
#
|
96
|
+
# @return [Boolean] Returns `true` if the access key id and secret access key are both set.
|
97
|
+
def set?
|
98
|
+
MoxiworksPlatform::Credentials.set?
|
99
|
+
end
|
100
|
+
|
101
|
+
# Removing the secret access key from the default inspect string.
|
102
|
+
# @api private
|
103
|
+
def inspect
|
104
|
+
"#<#{self.class.name} access_key_id=#{platform_identifier.inspect}>"
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module MoxiworksPlatform
|
2
|
+
module Exception
|
3
|
+
# general error for moxi_works_platform all other errors are children of
|
4
|
+
class PlatformError < StandardError; end
|
5
|
+
|
6
|
+
# an expected argument is not defined, or the argument is in an unexpected form
|
7
|
+
class ArgumentError < PlatformError; end
|
8
|
+
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'base64'
|
3
|
+
|
4
|
+
module MoxiworksPlatform
|
5
|
+
# provides underlying logic for connecting to Moxi Works Platform over HTTPS
|
6
|
+
class Resource
|
7
|
+
|
8
|
+
# keep a list of attr_accessors defined in this class
|
9
|
+
#
|
10
|
+
# used to convert Resource child object into parameters required for saving
|
11
|
+
# in Moxi Works Platform
|
12
|
+
#
|
13
|
+
def self.attr_accessor(*vars)
|
14
|
+
@attributes ||= []
|
15
|
+
@attributes.concat vars
|
16
|
+
super(*vars)
|
17
|
+
end
|
18
|
+
|
19
|
+
# all available accessors defined in this class
|
20
|
+
#
|
21
|
+
# @return [Array][String] all defined accessors of this class
|
22
|
+
def self.attributes
|
23
|
+
@attributes
|
24
|
+
end
|
25
|
+
|
26
|
+
# HTTP headers required to connect to Moxi Works Platform
|
27
|
+
#
|
28
|
+
# @return [Hash] formatted headers suitable for a RestClient connection
|
29
|
+
def self.headers
|
30
|
+
{
|
31
|
+
Authorization: auth_header,
|
32
|
+
Accept: accept_header,
|
33
|
+
'Content-Type' => content_type
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
# formatted Authorization header content
|
38
|
+
#
|
39
|
+
# @return [String] Authorization header content
|
40
|
+
def self.auth_header
|
41
|
+
raise 'MoxiworksPlatform::Credentials must be set before using' unless
|
42
|
+
MoxiworksPlatform::Credentials.set?
|
43
|
+
identifier = MoxiworksPlatform::Credentials.platform_identifier
|
44
|
+
secret = MoxiworksPlatform::Credentials.platform_secret
|
45
|
+
'Basic ' + Base64.encode64("#{identifier}:#{secret}").gsub(/\n/, '')
|
46
|
+
end
|
47
|
+
|
48
|
+
# formatted Accept header content
|
49
|
+
#
|
50
|
+
# @return [String] Accept header content
|
51
|
+
def self.accept_header
|
52
|
+
'application/vnd.moxi-platform+json;version=1'
|
53
|
+
end
|
54
|
+
|
55
|
+
# formatted Content-Type header
|
56
|
+
#
|
57
|
+
# @return [String] Content-Type header content
|
58
|
+
def self.content_type
|
59
|
+
'application/x-www-form-urlencoded'
|
60
|
+
end
|
61
|
+
|
62
|
+
# maps Hash values to Instance variables for mapping JSON object values to our Class attributes
|
63
|
+
#
|
64
|
+
def initialize(hash={})
|
65
|
+
hash.each do |key,val|
|
66
|
+
instance_variable_set("@#{key}", val)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# all available accessors defined in this class
|
71
|
+
#
|
72
|
+
# @return [Array][String] all defined accessors of this class
|
73
|
+
def attributes
|
74
|
+
self.class.attributes
|
75
|
+
end
|
76
|
+
|
77
|
+
# convert this class into a Hash structure where attributes are Hash key names and attribute values are Hash values
|
78
|
+
#
|
79
|
+
# @return [Hash] with keys mapped to class attribute names
|
80
|
+
def to_hash
|
81
|
+
hash = {}
|
82
|
+
self.attributes.each {|attr| hash[attr.to_sym] = self.send(attr)}
|
83
|
+
hash
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'moxiworks_platform/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "moxiworks_platform"
|
8
|
+
spec.version = MoxiworksPlatform::VERSION
|
9
|
+
spec.authors = ["Tres Wong-Godfrey"]
|
10
|
+
spec.email = ["tres.wong-godfrey@moxiworks.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Ruby Moxi Works Platform Client}
|
13
|
+
spec.homepage = 'http://github.io/moxiworks-platform/moxiworks-platform-ruby'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
23
|
+
spec.add_development_dependency 'rest-client'
|
24
|
+
spec.add_dependency 'hashie'
|
25
|
+
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: moxiworks_platform
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tres Wong-Godfrey
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rest-client
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: hashie
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- tres.wong-godfrey@moxiworks.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- Gemfile
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- bin/console
|
97
|
+
- bin/setup
|
98
|
+
- lib/moxiworks_platform.rb
|
99
|
+
- lib/moxiworks_platform/config.rb
|
100
|
+
- lib/moxiworks_platform/contact.rb
|
101
|
+
- lib/moxiworks_platform/credentials.rb
|
102
|
+
- lib/moxiworks_platform/exception.rb
|
103
|
+
- lib/moxiworks_platform/resource.rb
|
104
|
+
- lib/moxiworks_platform/version.rb
|
105
|
+
- moxiworks_platform.gemspec
|
106
|
+
homepage: http://github.io/moxiworks-platform/moxiworks-platform-ruby
|
107
|
+
licenses: []
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.4.5.1
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: Ruby Moxi Works Platform Client
|
129
|
+
test_files: []
|
130
|
+
has_rdoc:
|