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 +4 -4
- data/lib/finapps/rest/orders.rb +14 -22
- data/lib/finapps/version.rb +1 -1
- data/spec/rest/orders_spec.rb +24 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48c57f559c6d4687e2fa9b6b38551e333bad8980
|
4
|
+
data.tar.gz: 321871ba46163cc9bd419bccde9f97abd53705cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac05fb45a25f60dd341bed1133d8a4cd316996d99c19084cdacf34724e70031f7a603290fa98b8585102df868f0eb361c03891c3058899fc16943db2171c4189
|
7
|
+
data.tar.gz: 7d7f8ce65c7c354802915fee55e77c050beec6cc0cec2cdb247818d94888e9bde98704ee55fd6d8b4330613856c36492de8ffc376f451ad4de19a92bb63637a4
|
data/lib/finapps/rest/orders.rb
CHANGED
@@ -12,20 +12,18 @@ module FinApps
|
|
12
12
|
super params
|
13
13
|
end
|
14
14
|
|
15
|
-
# GET /v2/list/orders
|
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
|
-
#
|
23
|
-
def list
|
24
|
-
super
|
25
|
-
|
26
|
-
|
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
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
data/lib/finapps/version.rb
CHANGED
data/spec/rest/orders_spec.rb
CHANGED
@@ -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
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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.
|
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-
|
11
|
+
date: 2017-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: finapps_core
|