finapps 2.2.11 → 2.2.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9345f2ee1b07ebc04aaafd850699f01d7410c75
4
- data.tar.gz: 7f1363fcc09f46ad078f900eccde69d9a007ec74
3
+ metadata.gz: 48c57f559c6d4687e2fa9b6b38551e333bad8980
4
+ data.tar.gz: 321871ba46163cc9bd419bccde9f97abd53705cb
5
5
  SHA512:
6
- metadata.gz: 9e0fbdf8e8b2307aaf9a897316c619fc7500969095393605bf8d16537e4b84c5405a797b86d233d2338d803e61f80d8fa73c6abd08c474eb34fd02cd4557cefd
7
- data.tar.gz: ef218718b47c393cb40a14513dfb14e2e9be8295bef9a7ebe97cb271965c7a5da2986062e5fa1f8ad0f9bb5d128e8bd00f1d56211610c91f5c99a57f18c97606
6
+ metadata.gz: ac05fb45a25f60dd341bed1133d8a4cd316996d99c19084cdacf34724e70031f7a603290fa98b8585102df868f0eb361c03891c3058899fc16943db2171c4189
7
+ data.tar.gz: 7d7f8ce65c7c354802915fee55e77c050beec6cc0cec2cdb247818d94888e9bde98704ee55fd6d8b4330613856c36492de8ffc376f451ad4de19a92bb63637a4
@@ -12,20 +12,18 @@ module FinApps
12
12
  super params
13
13
  end
14
14
 
15
- # GET /v2/list/orders/:page/:requested/:sort/:asc
15
+ # GET /v2/list/orders?page=1&requested=25&sort=-date
16
16
  # :page - page number requested
17
17
  # :requested - number of results per page requested
18
18
  # :sort - sort order
19
19
  # options:
20
20
  # date - the date of the order
21
21
  # status - the status of the order
22
- # :asc - sort order true for asc false for desc
23
- def list # (params=nil) # params hash with optional keys [:page, :requested, :sort, :asc]
24
- super 'orders?page=1&requested=500&sort=-date'
25
- # TODO: change to support https://github.com/finapps/api/blob/develop/misc/docs/iav.md#get-list-of-orders
26
- # return super 'orders?page=1&requested=500&sort=-date' # if params.nil?
27
- # raise FinAppsCore::InvalidArgumentsError.new 'Invalid argument: params' unless params.is_a? Hash
28
- # super build_path(params)
22
+ # descending - append "-" before option for descending sort
23
+ def list(params=nil) # params hash with optional keys [:page, :sort, :requested]
24
+ return super if params.nil?
25
+ raise FinAppsCore::InvalidArgumentsError.new 'Invalid argument: params' unless params.is_a? Hash
26
+ super build_path(params)
29
27
  end
30
28
 
31
29
  def update(id, params)
@@ -40,20 +38,14 @@ module FinApps
40
38
  super params, path
41
39
  end
42
40
 
43
- # private
44
- #
45
- # def build_path(p)
46
- # # TODO: change to support https://github.com/finapps/api/blob/develop/misc/docs/iav.md#get-list-of-orders
47
- #
48
- # page = p[:page] || 1
49
- # requested = p[:requested] || 100
50
- # sort = p[:sort] || 'date'
51
- # asc = p[:asc]
52
- # end_point = 'orders'
53
- # path = end_point.dup
54
- # [page, requested, sort, asc].each_with_index {|a| path << "/#{ERB::Util.url_encode(a)}" }
55
- # path
56
- # end
41
+ private
42
+
43
+ def build_path(p)
44
+ page = p[:page] ? "page=#{ERB::Util.url_encode(p[:page])}" : ''
45
+ requested = p[:requested] ? "&requested=#{ERB::Util.url_encode(p[:requested])}" : ''
46
+ sort = p[:sort] ? "&sort=#{ERB::Util.url_encode(p[:sort])}" : ''
47
+ "#{end_point}?#{page}#{requested}#{sort}"
48
+ end
57
49
  end
58
50
  end
59
51
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module FinApps
3
- VERSION = '2.2.11'
3
+ VERSION = '2.2.12'
4
4
  end
@@ -1,4 +1,6 @@
1
1
  # frozen_string_literal: true
2
+ require 'spec_helpers/client'
3
+
2
4
  RSpec.describe FinApps::REST::Orders do
3
5
  include SpecHelpers::Client
4
6
 
@@ -64,16 +66,28 @@ RSpec.describe FinApps::REST::Orders do
64
66
  it('returns no error messages') { expect(subject[ERROR_MESSAGES]).to be_empty }
65
67
  end
66
68
 
67
- # context 'when including partial params' do
68
- # subject { FinApps::REST::Orders.new(client).list(params) }
69
- # let(:params) { {page: 2, sort: 'status'} }
70
- #
71
- # it { expect { subject }.not_to raise_error }
72
- # it('returns an array') { expect(subject).to be_a(Array) }
73
- # it('performs a get and returns the response') { expect(subject[RESULTS]).to respond_to(:orders) }
74
- # it('each order contains a consumer_id') { expect(subject[RESULTS].orders).to all(respond_to(:consumer_id)) }
75
- # it('returns no error messages') { expect(subject[ERROR_MESSAGES]).to be_empty }
76
- # end
69
+ context 'when invalid params are provided' do
70
+ subject { FinApps::REST::Orders.new(client).list(invalid_params) }
71
+ let(:invalid_params) { %w(this is an array) }
72
+
73
+ it { expect { subject }.to raise_error(FinAppsCore::InvalidArgumentsError) }
74
+ end
75
+
76
+ context 'when including valid params' do
77
+ subject { FinApps::REST::Orders.new(client).list(params) }
78
+ let(:params) { {page: 2, sort: 'status'} }
79
+
80
+ it { expect { subject }.not_to raise_error }
81
+ it('returns an array') { expect(subject).to be_a(Array) }
82
+ it('performs a get and returns the response') { expect(subject[RESULTS]).to respond_to(:orders) }
83
+ it('each order contains a consumer_id') { expect(subject[RESULTS].orders).to all(respond_to(:consumer_id)) }
84
+ it('returns no error messages') { expect(subject[ERROR_MESSAGES]).to be_empty }
85
+ it 'sends proper request' do
86
+ subject
87
+ url = "#{FinAppsCore::REST::Defaults::DEFAULTS[:host]}/v2/orders?page=2&sort=status"
88
+ expect(WebMock).to have_requested(:get, url)
89
+ end
90
+ end
77
91
  end
78
92
 
79
93
  describe '#update' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: finapps
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.11
4
+ version: 2.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erich Quintero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-28 00:00:00.000000000 Z
11
+ date: 2017-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: finapps_core