sift-partner 0.0.3 → 0.0.4

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: 2ffbcc3b8821ea80e55772aec21ba849a5bc8c08
4
- data.tar.gz: 0ad11555eaf96e0e6d8a60eb12b392ad72913d21
3
+ metadata.gz: 7987ee5a58921058cdbb5c708746f0eda484d770
4
+ data.tar.gz: a061b87759f04a37665174eb55a73423fb1fc178
5
5
  SHA512:
6
- metadata.gz: 8e8146c86622681634be4cdc83e38b3f01fc071f500261c3b5da94024a41cafa8676d52fb9ba0aa9dc2cee8ff3e4d87897b425c177f28d5109360967ddbc242a
7
- data.tar.gz: 5dbb787221a05ad9b8b9e7bb9cd268928c7afae0c3332a0d90c51012dab6d2d38636024c8fba599c82e5c3e70377270539666d29ea0633da967881f53f34719d
6
+ metadata.gz: e0b58bb159cb059d76f28d14d0a0a683620016a387917a70cd9f79f6bb3ab665e34f972178aec977b42a0f91e0f6adf91d52c286f012a95f37e6e7e6972539d8
7
+ data.tar.gz: c80cd09c8a11e70a7ce0421ed4ff001fdc0575475400bc4aec1cd2dd7c0a98c07bf39e59bf28d9487f4c856125140bc22dcc3ca448010536fb736e3180741737
@@ -59,14 +59,17 @@ module SiftPartner
59
59
 
60
60
  end
61
61
 
62
- # Gets a listing of the ids and keys for all merchant accounts that have
63
- # been created by this partner.
62
+ # Gets a listing of the ids and keys for merchant accounts that have
63
+ # been created by this partner. This will return up to 100 results
64
+ # at a time.
64
65
  #
65
66
  # When successful, returns a hash including the key :data, which is an
66
67
  # array of account descriptions. (Each element has the same structure as a
67
- # single response from new_account).
68
- def get_accounts()
69
- http_get(accounts_url)
68
+ # single response from new_account). If the key :has_more is true, then
69
+ # pass the :next_ref value into this function again to get the next set
70
+ # of results.
71
+ def get_accounts(next_ref = nil)
72
+ http_get(next_ref ? next_ref : accounts_url)
70
73
  end
71
74
 
72
75
  # Updates the configuration which controls http notifications for all merchant
@@ -1,4 +1,4 @@
1
1
  module SiftPartner
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  API_VERSION = "3"
4
4
  end
@@ -123,20 +123,40 @@ describe SiftPartner::Client do
123
123
  end
124
124
 
125
125
  it "should march through account listing flow" do
126
- stub_request(:get, /https:\/\/.*partner\.siftscience\.com\/v3\/partners\/#{partner_id}\/accounts/).
126
+ stub_request(:get, /https:\/\/.*partner\.siftscience\.com\/v3\/partners\/#{partner_id}\/accounts\z/).
127
+ to_return(
128
+ {:body =>
129
+ { "type" => "partner_account", "data" => [expected_account_body.to_json],
130
+ "hasMore" => true,
131
+ "nextRef" => "https://partner.siftscience.com/v3/partners/#{partner_id}/accounts?afterId=1234567890abcdef",
132
+ "totalResults" => 2}.to_json,
133
+ :status => 200,
134
+ :headers => {}}
135
+ )
136
+ expected_account_body["account_id"] = "1234567890abcdff"
137
+ stub_request(:get, /https:\/\/.*partner\.siftscience\.com\/v3\/partners\/#{partner_id}\/accounts\?afterId=1234567890abcdef/).
127
138
  to_return(
128
139
  {:body =>
129
140
  { "type" => "partner_account", "data" => [expected_account_body.to_json],
130
141
  "hasMore" => false,
131
142
  "nextRef" => nil,
132
- "totalResults" => 1}.to_json,
143
+ "totalResults" => 2}.to_json,
133
144
  :status => 200,
134
145
  :headers => {}}
135
146
  )
136
147
  partner_client = SiftPartner::Client.new(partner_api_key, partner_id)
137
148
  response = partner_client.get_accounts()
138
149
  response.should_not be_nil
139
- response["totalResults"].should eq(1)
150
+ response["nextRef"].should_not be_nil
151
+ response["hasMore"].should be_truthy
152
+ response["totalResults"].should eq(2)
153
+ next_ref = response["nextRef"]
154
+
155
+ response = partner_client.get_accounts(next_ref)
156
+ response.should_not be_nil
157
+ response["hasMore"].should be_falsey
158
+ response["nextRef"].should be_nil
159
+ response["totalResults"].should eq(2)
140
160
  end
141
161
 
142
162
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sift-partner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Beppu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-09 00:00:00.000000000 Z
11
+ date: 2016-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec