moxiworks_platform 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af96fed391f3936ebed6ede94c6f4b05d8ddf9d5
4
- data.tar.gz: 1a4a034af70aad0fdbbe149a7d959d7ce0ed4150
3
+ metadata.gz: 4e8d7e2206d39d1362ad4ceefc7bf01bdfffef99
4
+ data.tar.gz: ebc93c1f26cd1dc020e9ed47a59c5f5509837c59
5
5
  SHA512:
6
- metadata.gz: 5e37c415d0b7071b1a6fdd9913f6f79e33de27cd9e6659cc8e76b02f46785c7833c0332966048083cd4ca64d8154826468d39fc3f1326b898ac6e0908a152b01
7
- data.tar.gz: 7b02fec0cc6fea7e4ae335748f9e9b22abfa27a96059f6b7b0b3d7b27c99eec6cc492c2ee3ebddf4bfffd690be8eb4e3c0774b38b2ec59433bd60f31d87dc8a4
6
+ metadata.gz: ab84414000cc684c9bde839040e497824255a19f46bb49757f8a55035c64754df3eb41e0e110da8afff2e3ee110dfc93e967e58a3fe379e7b70efd288a549e6b
7
+ data.tar.gz: 7231087fc9c00c494242aca80635f7d6dc14308d08c649713bc2c56222afcf2ffc4ce97268fb25f3d4d97a190ff8b14840f21e77bc1fe7d1e799c48e4996864e
data/README.md CHANGED
@@ -19,10 +19,15 @@ Or install it yourself as:
19
19
  ## Usage
20
20
 
21
21
  ```ruby
22
+ require 'moxiworks_platform'
23
+
24
+
22
25
  platform_identifier = 'abc1234'
23
26
  platform_secret = 'secretkey'
24
- require 'moxiworks_platform'
27
+
28
+
25
29
  MoxiworksPlatform::Credentials.new(platform_identifier, platform_secret)
30
+
26
31
  contact = MoxiworksPlatform::Contact.create(moxi_works_agent_id: '123abcd', partner_contact_id: 'my_unique_id')
27
32
  ```
28
33
 
@@ -34,5 +39,5 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
34
39
 
35
40
  ## Contributing
36
41
 
37
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/moxiworks_platform.
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/moxiworks-platform/moxiworks-ruby
38
43
 
@@ -19,14 +19,6 @@ module MoxiworksPlatform
19
19
  # @return [String] your system's unique ID for the contact
20
20
  attr_accessor :partner_contact_id
21
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 :moxi_works_contact_id
28
-
29
-
30
22
  # @!attribute business_website
31
23
  # the full URL of the business website to be associated with this Contact
32
24
  #
@@ -404,6 +396,11 @@ module MoxiworksPlatform
404
396
  # @option opts [Integer] :search_min_year_built the minimum year built this contact has used as criteria when searching for a listing
405
397
  # @option opts [String] :search_property_types property types this contact has searched for; ex: 'Single Family, Condo, Townhouse'
406
398
  #
399
+ # @return [MoxiworksPlatform::Contact]
400
+ #
401
+ # @raise ::MoxiworksPlatform::Exception::ArgumentError if required
402
+ # named parameters aren't included
403
+ #
407
404
  # @example
408
405
  # MoxiworksPlatform::Contact.create(
409
406
  # moxi_works_agent_id: '123abc',
@@ -421,7 +418,7 @@ module MoxiworksPlatform
421
418
  # primary_phone_number: '123213',
422
419
  # property_mls_id: '1232312abcv',
423
420
  # secondary_phone_number: '1234567890')
424
- # @return [MoxiworksPlatform::Contact]
421
+ #
425
422
  def self.create(opts={})
426
423
  self.send_request(:post, opts)
427
424
  end
@@ -431,11 +428,60 @@ module MoxiworksPlatform
431
428
  # @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
429
  # @option opts [String] :partner_contact_id *REQUIRED* Your system's unique ID for this contact.
433
430
  #
434
- # returns [MoxiworksPlatform::Contact]
431
+ # @return [MoxiworksPlatform::Contact]
432
+ #
433
+ # @raise ::MoxiworksPlatform::Exception::ArgumentError if required
434
+ # named parameters aren't included
435
+ #
435
436
  def self.find(opts={})
436
- self.send_request(:get, opts)
437
+ url = "#{MoxiworksPlatform::Config.url}/api/contacts/#{opts[:partner_contact_id]}"
438
+ self.send_request(:get, opts, url)
439
+ end
440
+
441
+ # Search an Agent's Contacts in Moxi Works Platform
442
+ # @param [Hash] opts named parameter Hash
443
+ # @option opts [String] :moxi_works_agent_id *REQUIRED* The Moxi Works Agent ID for the agent to which this contact is to be associated
444
+ #
445
+ # optional Search parameters
446
+ #
447
+ # @option opts [String] :contact_name full name of the contact
448
+ # @option opts [String] :email_address full email address of the contact
449
+ # @option opts [String] :phone_number full phone number of the contact
450
+ #
451
+ # @return [Array] containing MoxiworkPlatform::Contact objects
452
+ #
453
+ # @raise ::MoxiworksPlatform::Exception::ArgumentError if required
454
+ # named parameters aren't included
455
+ #
456
+ # @example
457
+ # results = MoxiworksPlatform::Contact.search(
458
+ # moxi_works_agent_id: '123abc',
459
+ # contact_name: 'george p warshington',
460
+ # )
461
+ #
462
+ def self.search(opts={})
463
+ url ||= "#{MoxiworksPlatform::Config.url}/api/contacts"
464
+ required_opts = [:moxi_works_agent_id]
465
+ required_opts.each do |opt|
466
+ raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if
467
+ opts[opt].nil? or opts[opt].empty?
468
+ end
469
+ results = []
470
+ RestClient::Request.execute(method: :get,
471
+ url: url,
472
+ payload: opts, headers: self.headers) do |response|
473
+ puts response if MoxiworksPlatform::Config.debug
474
+ self.check_for_error_in_response(response)
475
+ json = JSON.parse(response)
476
+ json.each do |r|
477
+ results << MoxiworksPlatform::Contact.new(r) unless r.nil? or r.empty?
478
+ end
479
+ end
480
+ results
437
481
  end
438
482
 
483
+
484
+
439
485
  # Updates a previously created Contact in Moxi Works Platform
440
486
  # @param [Hash] opts
441
487
  # @option opts [String] :moxi_works_agent_id *REQUIRED* The Moxi Works Agent ID for the agent to which this contact is to be associated
@@ -443,7 +489,6 @@ module MoxiworksPlatform
443
489
  #
444
490
  # optional Contact parameters
445
491
  #
446
- # @option opts [String] :moxi_works_contact_id Moxi Works Platform contact ID
447
492
  # @option opts [String] :business_website full url of a website associated with this contact
448
493
  # @option opts [String] :contact_name full name of this contact in format "Firstname Middlename Lastname"
449
494
  # @option opts [String, Enumerated] :gender can be "male" or "female" or "m" or "f"
@@ -497,6 +542,9 @@ module MoxiworksPlatform
497
542
  #
498
543
  # @return [MoxiworksPlatform::Contact]
499
544
  #
545
+ # @raise ::MoxiworksPlatform::Exception::ArgumentError if required
546
+ # named parameters aren't included
547
+ #
500
548
  # @example
501
549
  # MoxiworksPlatform::Contact.update(
502
550
  # moxi_works_agent_id: '123abc',
@@ -514,9 +562,11 @@ module MoxiworksPlatform
514
562
  # primary_phone_number: '123213',
515
563
  # property_mls_id: '1232312abcv',
516
564
  # secondary_phone_number: '1234567890')
565
+ #
566
+ #
517
567
  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]}"
568
+ opts[:contact_id] = opts[:partner_contact_id]
569
+ url = "#{MoxiworksPlatform::Config.url}/api/contacts/#{opts[:partner_contact_id]}"
520
570
  self.send_request(:put, opts, url)
521
571
  end
522
572
 
@@ -530,6 +580,9 @@ module MoxiworksPlatform
530
580
  #
531
581
  # @return [Boolean] -- success of the delete action
532
582
  #
583
+ # @raise ::MoxiworksPlatform::Exception::ArgumentError if required
584
+ # named parameters aren't included
585
+ #
533
586
  # @example
534
587
  # success = MoxiWorksPlatform::Contact.delete(moxi_works_agent_id: '123abcd', partner_contact_id: 'myUniqueContactId' )
535
588
  #
@@ -558,7 +611,6 @@ module MoxiworksPlatform
558
611
  #
559
612
  # optional Contact parameters
560
613
  #
561
- # @option opts [String] :moxi_works_contact_id Moxi Works Platform contact ID
562
614
  # @option opts [String] :business_website full url of a website associated with this contact
563
615
  # @option opts [String] :contact_name full name of this contact in format "Firstname Middlename Lastname"
564
616
  # @option opts [String, Enumerated] :gender can be "male" or "female" or "m" or "f"
@@ -612,15 +664,15 @@ module MoxiworksPlatform
612
664
  #
613
665
  # @param [String] url The full URLto connect to
614
666
  # @return [MoxiworksPlatform::Contact]
667
+ #
615
668
  def self.send_request(method, opts={}, url=nil)
616
669
  url ||= "#{MoxiworksPlatform::Config.url}/api/contacts"
617
- opts[:contact_id] = opts[:partner_contact_id] || opts[:moxi_works_contact_id]
618
- required_opts = [:moxi_works_agent_id, :contact_id]
670
+ required_opts = [:moxi_works_agent_id, :partner_contact_id]
619
671
  required_opts.each do |opt|
620
- message = opt == :contact_id ? 'partner_contact_id or moxi_works_contact_id required' : "#{opt} required"
621
- raise ::MoxiworksPlatform::Exception::ArgumentError, message if
672
+ raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if
622
673
  opts[opt].nil? or opts[opt].empty?
623
674
  end
675
+ opts[:contact_id] = opts[:partner_contact_id]
624
676
  contact = nil
625
677
  RestClient::Request.execute(method: method,
626
678
  url: url,
@@ -646,7 +698,7 @@ module MoxiworksPlatform
646
698
  # contact.primary_email_address = 'j.jonah.jameson@househun.ter'
647
699
  # contact.save
648
700
  def save
649
- MoxiworksPlatform::Contact.create(self.to_hash)
701
+ MoxiworksPlatform::Contact.update(self.to_hash)
650
702
  end
651
703
 
652
704
  # Delete an instance of MoxiWorksPlatform::Contact from Moxi Works Platform
@@ -656,6 +708,7 @@ module MoxiworksPlatform
656
708
  # @example
657
709
  # contact = MoxiWorksPlatform::Contact.find(moxi_works_agent_id: '123abcd', partner_contact_id: 'myUniqueContactId' )
658
710
  # success = contact.delete
711
+ #
659
712
  def delete
660
713
  MoxiworksPlatform::Contact.delete(self.to_hash)
661
714
  end
@@ -63,6 +63,7 @@ module MoxiworksPlatform
63
63
  def self.check_for_error_in_response(response)
64
64
  begin
65
65
  json = JSON.parse(response)
66
+ return if json.is_a?(Array)
66
67
  rescue => e
67
68
  raise MoxiworksPlatform::Exception::RemoteRequestFailure, "unable to parse remote response #{e}\n response:\n #{response}"
68
69
  end
@@ -1,3 +1,3 @@
1
1
  module MoxiworksPlatform
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -9,8 +9,9 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Tres Wong-Godfrey"]
10
10
  spec.email = ["tres.wong-godfrey@moxiworks.com"]
11
11
 
12
+ spec.description = %q{Moxi Works Platform Client Library For Ruby. Partners can use the Moxi Works Platform Library to quickly integrate into the Moxi Works Platform}
12
13
  spec.summary = %q{Ruby Moxi Works Platform Client}
13
- spec.homepage = 'https://github.io/moxiworks-platform/moxiworks-ruby'
14
+ spec.homepage = 'https://github.com/moxiworks-platform/moxiworks-ruby'
14
15
 
15
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
17
  spec.bindir = "exe"
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.1.0
4
+ version: 0.1.1
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-06 00:00:00.000000000 Z
11
+ date: 2016-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,7 +66,8 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description:
69
+ description: Moxi Works Platform Client Library For Ruby. Partners can use the Moxi
70
+ Works Platform Library to quickly integrate into the Moxi Works Platform
70
71
  email:
71
72
  - tres.wong-godfrey@moxiworks.com
72
73
  executables: []
@@ -89,7 +90,7 @@ files:
89
90
  - lib/moxiworks_platform/resource.rb
90
91
  - lib/moxiworks_platform/version.rb
91
92
  - moxiworks_platform.gemspec
92
- homepage: https://github.io/moxiworks-platform/moxiworks-ruby
93
+ homepage: https://github.com/moxiworks-platform/moxiworks-ruby
93
94
  licenses: []
94
95
  metadata: {}
95
96
  post_install_message: