riq 1.0.2 → 1.1.3
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/.travis.yml +5 -0
- data/Gemfile +1 -5
- data/README.md +14 -6
- data/lib/riq/batch_manager.rb +6 -1
- data/lib/riq/client.rb +1 -0
- data/lib/riq/list.rb +1 -1
- data/riq.gemspec +6 -8
- data/test/test_account.rb +19 -5
- data/test/test_batch_manager.rb +13 -4
- data/test/test_contact.rb +24 -6
- data/test/test_event.rb +15 -4
- data/test/test_list_item.rb +13 -2
- data/test/tester.rb +32 -0
- data/vcr_cassettes/global.yml +930 -0
- metadata +54 -16
- data/test/test.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b20c9ddfd74935d80dcf38e3629e1e8e53962d17
|
4
|
+
data.tar.gz: 5ca2c0a6bf4ea725503de340dfa497e8116a8720
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e96e96be3db9b502790cac618cb647474843e36408c8bdf0ba53c80e53ab8d5b7b353d4463c84169634349516b0c8ea3599de3b37e6c35c37ce7f10ae648c24f
|
7
|
+
data.tar.gz: bac00f6b2740d67c111392f89739e3c28b5f590f36f2c173c77ab8daa2ccc53d94178add5f5fda513cd9ed8fec26ebb386870c378f0fbe045b77fd39b5f0706d
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,20 @@
|
|
1
|
-
# RelateIQ Ruby SDK
|
1
|
+
# RelateIQ Ruby SDK
|
2
|
+
[](http://badge.fury.io/rb/riq)
|
3
|
+
[](https://travis-ci.org/relateiq/ruby-sdk)
|
4
|
+
|
2
5
|
|
3
6
|
A full featured API interface for interacting with the [RelateIQ](https://relateiq.com) API.
|
4
7
|
|
5
|
-
##
|
8
|
+
## Status
|
9
|
+
|
10
|
+
|Badge (click for more info)|Explanation|
|
11
|
+
|-|-|
|
12
|
+
|[](http://www.rubydoc.info/gems/riq)|% of methods documented|
|
13
|
+
|[](https://codeclimate.com/github/relateiq/ruby-sdk/coverage)|% of methods tested|
|
14
|
+
|[](https://codeclimate.com/github/relateiq/ruby-sdk/code)|Overall code quality (4.0 is best)|
|
15
|
+
|[](https://gemnasium.com/relateiq/ruby-sdk)|Dependency freshness|
|
16
|
+
|[](http://opensource.org/licenses/MIT)|What can you use this for?|
|
6
17
|
|
7
|
-
<!--[](http://badge.fury.io/rb/riq)-->
|
8
|
-
[](http://badge.fury.io/rb/riq)
|
9
|
-
<!--[](http://opensource.org/licenses/MIT)-->
|
10
18
|
|
11
19
|
## Code Examples
|
12
20
|
|
@@ -30,4 +38,4 @@ A full featured API interface for interacting with the [RelateIQ](https://relate
|
|
30
38
|
## Helpful Links
|
31
39
|
|
32
40
|
* [Full ruby docs](http://www.rubydoc.info/gems/riq)
|
33
|
-
* [Examples and API docs](https://api.relateiq.com/#/ruby)
|
41
|
+
* [Examples and API docs](https://api.relateiq.com/#/ruby)
|
data/lib/riq/batch_manager.rb
CHANGED
@@ -44,12 +44,17 @@ module RIQ
|
|
44
44
|
# @return [RIQObject]
|
45
45
|
def first
|
46
46
|
reset_cache
|
47
|
-
|
47
|
+
o = fetch_options.dup
|
48
|
+
self.send(:fetch_options=, {_limit: 1})
|
49
|
+
r = fetch_page.first
|
50
|
+
self.send(:fetch_options=, o)
|
51
|
+
r
|
48
52
|
end
|
49
53
|
|
50
54
|
# Set fetch options
|
51
55
|
# @param opts [Hash] Where values are either strings or arrays
|
52
56
|
def fetch_options=(opts = {})
|
57
|
+
# these need to be updated with API changes
|
53
58
|
valid_keys = [:_ids, :_start, :_limit, :contactIds, :accountIds, :modifiedDate]
|
54
59
|
reset_cache
|
55
60
|
options = {}
|
data/lib/riq/client.rb
CHANGED
@@ -85,6 +85,7 @@ module RIQ
|
|
85
85
|
|
86
86
|
def process_response(resp)
|
87
87
|
# pp "processing #{resp}, code: #{resp.code}"
|
88
|
+
# puts resp.parsed_response['name']
|
88
89
|
if resp.code == 503
|
89
90
|
raise NotImplementedError, 'This function is not currently supported by RelateIQ'
|
90
91
|
elsif resp.code == 404
|
data/lib/riq/list.rb
CHANGED
data/riq.gemspec
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
# lib = File.expand_path('../lib', __FILE__)
|
3
|
-
# $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
2
|
|
5
3
|
Gem::Specification.new do |spec|
|
6
4
|
spec.name = 'riq'
|
7
|
-
spec.version = '1.
|
5
|
+
spec.version = '1.1.3'
|
8
6
|
spec.authors = ['David Brownman']
|
9
7
|
spec.email = ['david@relateiq.com']
|
10
8
|
spec.homepage = "https://github.com/relateiq/ruby-sdk"
|
@@ -12,8 +10,6 @@ Gem::Specification.new do |spec|
|
|
12
10
|
spec.description = 'Full featured ruby client for interacting with the RelateIQ API'
|
13
11
|
spec.license = 'MIT'
|
14
12
|
spec.files = `git ls-files -z`.split("\x0")
|
15
|
-
# spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
13
|
spec.require_paths = ['lib']
|
18
14
|
|
19
15
|
# 2.0 is min becuase use of refinements
|
@@ -21,9 +17,11 @@ Gem::Specification.new do |spec|
|
|
21
17
|
# spec.post_install_message = 'The power of relationship intelligence is in your hands!'
|
22
18
|
|
23
19
|
# prod dependencies
|
24
|
-
spec.add_dependency 'httparty', '0.13
|
20
|
+
spec.add_dependency 'httparty', '~> 0.13'
|
25
21
|
|
26
22
|
# dev dependencies
|
27
|
-
spec.add_development_dependency 'bundler', '~> 1
|
28
|
-
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1'
|
24
|
+
spec.add_development_dependency 'vcr', '~> 2.9'
|
25
|
+
spec.add_development_dependency 'webmock', '~> 1.21'
|
26
|
+
spec.add_development_dependency 'minitest', '~> 5.4'
|
29
27
|
end
|
data/test/test_account.rb
CHANGED
@@ -1,32 +1,44 @@
|
|
1
1
|
require 'minitest/autorun'
|
2
|
+
|
2
3
|
require_relative '../lib/riq'
|
3
4
|
|
5
|
+
def create_netflix
|
6
|
+
RIQ.account('54e6542fe4b01ad3b7362bc4')
|
7
|
+
end
|
8
|
+
|
9
|
+
def create_blank_account
|
10
|
+
RIQ.account
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_data_account
|
14
|
+
RIQ.account({name: 'Glengarry', field_values: {'0' => 3}})
|
15
|
+
end
|
16
|
+
|
4
17
|
describe RIQ::Account do
|
5
18
|
before do
|
6
19
|
RIQ.init
|
7
|
-
# netflix account ID
|
8
|
-
@netflix = RIQ.account('54e6542fe4b01ad3b7362bc4')
|
9
|
-
@a = RIQ.account
|
10
|
-
@dat = RIQ.account({name: 'Glengarry', field_values: {'0' => 3}})
|
11
20
|
end
|
12
21
|
|
13
22
|
describe '#new' do
|
14
23
|
it 'should get account' do
|
24
|
+
@netflix = create_netflix
|
15
25
|
@netflix.name.must_equal 'Netflix'
|
16
26
|
end
|
17
27
|
|
18
28
|
it 'should make blank account' do
|
29
|
+
@a = create_blank_account
|
19
30
|
@a.wont_be_nil
|
20
31
|
end
|
21
32
|
|
22
33
|
it 'should take a data hash' do
|
23
|
-
@dat =
|
34
|
+
@dat = create_data_account
|
24
35
|
@dat.name.wont_be_nil
|
25
36
|
end
|
26
37
|
end
|
27
38
|
|
28
39
|
describe '#save' do
|
29
40
|
it 'should create new account' do
|
41
|
+
@a = create_blank_account
|
30
42
|
@a.name = 'Delete Test Inc'
|
31
43
|
@a.field_value(2, '1')
|
32
44
|
@a.save
|
@@ -37,7 +49,9 @@ describe RIQ::Account do
|
|
37
49
|
|
38
50
|
describe "#field_value" do
|
39
51
|
it 'should fetch a field value' do
|
52
|
+
@netflix = create_netflix
|
40
53
|
@netflix.field_value(2).wont_be_nil
|
54
|
+
@dat = create_data_account
|
41
55
|
@dat.field_value(0).wont_be_nil
|
42
56
|
end
|
43
57
|
end
|
data/test/test_batch_manager.rb
CHANGED
@@ -9,12 +9,13 @@ describe RIQ::BatchManager do
|
|
9
9
|
|
10
10
|
describe '#accounts' do
|
11
11
|
it 'should get all accounts' do
|
12
|
+
# could limit this, but want it to make sure the default works
|
12
13
|
accounts = RIQ.accounts
|
13
14
|
accounts.each do |a|
|
14
15
|
a.id.wont_be_nil
|
15
16
|
a.name.wont_be_nil
|
16
17
|
@c += 1
|
17
|
-
break if @c >=
|
18
|
+
break if @c >= 5
|
18
19
|
end
|
19
20
|
@c.wont_equal 0
|
20
21
|
end
|
@@ -22,11 +23,12 @@ describe RIQ::BatchManager do
|
|
22
23
|
|
23
24
|
describe '#contacts' do
|
24
25
|
it 'should get all contacts' do
|
25
|
-
contacts = RIQ.contacts
|
26
|
+
contacts = RIQ.contacts({_limit: 3})
|
26
27
|
contacts.each do |con|
|
27
28
|
con.id.wont_be_nil
|
28
29
|
@c += 1
|
29
|
-
|
30
|
+
# need to test that it can cycle to the next call
|
31
|
+
break if @c >= 10
|
30
32
|
end
|
31
33
|
@c.wont_equal 0
|
32
34
|
end
|
@@ -43,7 +45,7 @@ describe RIQ::BatchManager do
|
|
43
45
|
lic = 0
|
44
46
|
l.list_items.each do |li|
|
45
47
|
lic += 1
|
46
|
-
break if lic >=
|
48
|
+
break if lic >= 3
|
47
49
|
end
|
48
50
|
lic.wont_equal 0
|
49
51
|
break if @c >= 20
|
@@ -58,6 +60,13 @@ describe RIQ::BatchManager do
|
|
58
60
|
c = RIQ.contacts.first
|
59
61
|
c.must_be_instance_of RIQ::Contact
|
60
62
|
end
|
63
|
+
|
64
|
+
it 'should not change fetch options' do
|
65
|
+
opts = {_limit: 15, _ids: '5550fd35e4b0da744884f69d'}
|
66
|
+
bm = RIQ.contacts(opts)
|
67
|
+
bm.first
|
68
|
+
bm.fetch_options.must_equal bm.fetch_options.merge(opts)
|
69
|
+
end
|
61
70
|
end
|
62
71
|
|
63
72
|
describe '#fetch_options' do
|
data/test/test_contact.rb
CHANGED
@@ -1,27 +1,42 @@
|
|
1
1
|
require 'minitest/autorun'
|
2
2
|
require_relative '../lib/riq'
|
3
3
|
|
4
|
+
def create_sammy
|
5
|
+
RIQ.contact('542b205be4b04cd81270dff9')
|
6
|
+
end
|
7
|
+
|
8
|
+
def create_blank_contact
|
9
|
+
RIQ.contact
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_data
|
13
|
+
RIQ.contact({properties: {'name' => ['david'], email: ['dab@relateiq.com']}})
|
14
|
+
end
|
15
|
+
|
4
16
|
describe RIQ::Contact do
|
5
17
|
before do
|
6
18
|
RIQ.init
|
7
|
-
# sammy's contact ID
|
8
|
-
@sammy = RIQ.contact('542b205be4b04cd81270dff9')
|
9
|
-
@c = RIQ.contact
|
10
|
-
@dat = RIQ.contact({properties: {'name' => ['david'], email: ['dab@relateiq.com']}})
|
11
19
|
end
|
12
20
|
|
13
21
|
describe '#new' do
|
14
22
|
it 'should get account' do
|
23
|
+
@sammy = create_sammy
|
15
24
|
@sammy.name.must_include 'Sammy Nammari'
|
16
25
|
end
|
17
26
|
|
18
|
-
it 'make blank contact' do
|
27
|
+
it 'should make blank contact' do
|
28
|
+
@c = create_blank_contact
|
19
29
|
@c.wont_be_nil
|
20
30
|
end
|
31
|
+
|
32
|
+
it 'should take a data hash' do
|
33
|
+
@dat = create_data
|
34
|
+
end
|
21
35
|
end
|
22
36
|
|
23
37
|
describe '#save' do
|
24
38
|
it 'should create new contact and delete it' do
|
39
|
+
@c = create_blank_contact
|
25
40
|
@c.add(:name, 'Ron Mexico')
|
26
41
|
@c.save
|
27
42
|
|
@@ -32,13 +47,15 @@ describe RIQ::Contact do
|
|
32
47
|
end
|
33
48
|
|
34
49
|
describe 'properties' do
|
35
|
-
it
|
50
|
+
it "should add new emails only if they're new" do
|
51
|
+
@sammy = create_sammy
|
36
52
|
@sammy.email.must_equal @sammy.add(:email, 'nammari@stanford.edu')
|
37
53
|
|
38
54
|
@sammy.email.wont_equal @sammy.add(:email, 'jammari@stanford.edu')
|
39
55
|
end
|
40
56
|
|
41
57
|
it 'should only take strings as properties' do
|
58
|
+
@c = create_blank_contact
|
42
59
|
@c.add(:phone, '867-5309').wont_be_empty
|
43
60
|
|
44
61
|
begin
|
@@ -53,6 +70,7 @@ describe RIQ::Contact do
|
|
53
70
|
|
54
71
|
describe '#upsert' do
|
55
72
|
it 'should upsert' do
|
73
|
+
@sammy = create_sammy
|
56
74
|
# this could be better
|
57
75
|
@sammy.email.must_equal @sammy.upsert.email
|
58
76
|
|
data/test/test_event.rb
CHANGED
@@ -1,27 +1,35 @@
|
|
1
1
|
require 'minitest/autorun'
|
2
2
|
require_relative '../lib/riq'
|
3
3
|
|
4
|
+
def create_blank_event
|
5
|
+
RIQ.event
|
6
|
+
end
|
7
|
+
|
8
|
+
def create_data_event
|
9
|
+
RIQ.event({subject: "My Sub", body: "Bodily harm", 'participantIds' => [{type: :email, value: 'fake@fakerelateiq.com'}]})
|
10
|
+
end
|
11
|
+
|
4
12
|
describe RIQ::Event do
|
5
13
|
before do
|
6
14
|
RIQ.init
|
7
|
-
# sammy's contact ID
|
8
|
-
@e = RIQ.event
|
9
|
-
@ev = RIQ.event({subject: "My Sub", body: "Very intersting body", 'participantIds' => [{type: :email, value: 'fake@fakerelateiq.com'}]})
|
10
15
|
end
|
11
16
|
|
12
17
|
describe '#new' do
|
13
18
|
it 'should start blank' do
|
19
|
+
@e = create_blank_event
|
14
20
|
@e.subject.must_be_nil
|
15
21
|
end
|
16
22
|
|
17
23
|
it 'should take a hash' do
|
24
|
+
@ev = create_data_event
|
18
25
|
@ev.subject.wont_be_nil
|
19
26
|
@ev.participant_ids.wont_be_empty
|
20
27
|
end
|
21
28
|
end
|
22
29
|
|
23
30
|
describe '#save' do
|
24
|
-
it 'should fail without subject'do
|
31
|
+
it 'should fail without subject' do
|
32
|
+
@e = create_blank_event
|
25
33
|
begin
|
26
34
|
@e.save
|
27
35
|
rescue RIQ::HTTPError
|
@@ -32,18 +40,21 @@ describe RIQ::Event do
|
|
32
40
|
end
|
33
41
|
|
34
42
|
it 'should save with data' do
|
43
|
+
@ev = create_data_event
|
35
44
|
@ev.save.must_be_kind_of Hash
|
36
45
|
end
|
37
46
|
end
|
38
47
|
|
39
48
|
describe '#add_participant' do
|
40
49
|
it 'should add a participant' do
|
50
|
+
@e = create_blank_event
|
41
51
|
p = {type: :email, value: 'good'}
|
42
52
|
@e.add_participant(p[:type], p[:value])
|
43
53
|
@e.participant_ids.must_include p
|
44
54
|
end
|
45
55
|
|
46
56
|
it 'should reject bad types' do
|
57
|
+
@e = create_blank_event
|
47
58
|
begin
|
48
59
|
@e.add_participant(:blarg, 'bad type')
|
49
60
|
rescue RIQ::RIQError
|
data/test/test_list_item.rb
CHANGED
@@ -1,24 +1,34 @@
|
|
1
1
|
require 'minitest/autorun'
|
2
2
|
require_relative '../lib/riq'
|
3
3
|
|
4
|
+
def create_blank_list_item
|
5
|
+
@l.list_item
|
6
|
+
end
|
7
|
+
|
8
|
+
def create_first
|
9
|
+
@l.list_items.first
|
10
|
+
end
|
11
|
+
|
4
12
|
describe RIQ::ListItem do
|
5
13
|
before do
|
6
14
|
RIQ.init
|
7
15
|
lid = '54ca9b25e4b0b29d80ce4b4e'
|
8
16
|
@l = RIQ.list(lid)
|
9
|
-
@li = @l.list_items.first
|
10
|
-
@blank = @l.list_item
|
11
17
|
end
|
12
18
|
|
13
19
|
describe '#field_value' do
|
14
20
|
it 'should return a value' do
|
21
|
+
@li = create_first
|
15
22
|
@li.field_value(0).wont_be_nil
|
23
|
+
|
24
|
+
@blank = create_blank_list_item
|
16
25
|
@blank.field_value(0).must_be_nil
|
17
26
|
end
|
18
27
|
end
|
19
28
|
|
20
29
|
describe '#save' do
|
21
30
|
it 'should create and delete' do
|
31
|
+
@blank = create_blank_list_item
|
22
32
|
@blank.field_value(0, 1)
|
23
33
|
@blank.contact_ids << RIQ.contacts.first.id
|
24
34
|
@blank.save
|
@@ -28,6 +38,7 @@ describe RIQ::ListItem do
|
|
28
38
|
end
|
29
39
|
|
30
40
|
it 'should update' do
|
41
|
+
@li = create_first
|
31
42
|
start = @li.field_value(0)
|
32
43
|
if start == '1'
|
33
44
|
@li.field_value(0, 0)
|
data/test/tester.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require "codeclimate-test-reporter"
|
2
|
+
CodeClimate::TestReporter.start
|
3
|
+
|
4
|
+
# testing!
|
5
|
+
require 'vcr'
|
6
|
+
|
7
|
+
VCR.configure do |c|
|
8
|
+
# important so the api keys don't matter
|
9
|
+
# need to match body for event cassettes, need to match query for anything with contacts/li/accounts
|
10
|
+
c.default_cassette_options = {match_requests_on: [:method, :path, :query, :body], record: :new_episodes}
|
11
|
+
|
12
|
+
c.cassette_library_dir = 'vcr_cassettes'
|
13
|
+
c.filter_sensitive_data('<API_KEY>') { ENV['RIQ_TEST_API_KEY'] }
|
14
|
+
c.filter_sensitive_data('<API_SECRET>') { ENV['RIQ_TEST_API_SECRET'] }
|
15
|
+
|
16
|
+
c.hook_into :webmock
|
17
|
+
c.before_record do |request|
|
18
|
+
# this prevents binary data from being written into the vcr
|
19
|
+
if request.response.body.encoding == Encoding::ASCII_8BIT
|
20
|
+
request.response.body = request.response.body.force_encoding('utf-8')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
# grab them all
|
24
|
+
# https://stackoverflow.com/questions/16533980/using-specific-vcr-cassette-based-on-request
|
25
|
+
c.around_http_request do |request|
|
26
|
+
VCR.use_cassette('global', &request)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
# require everything to run all tests
|
32
|
+
Dir["#{__dir__}/*_*.rb"].each{|f| require_relative f}
|