rally_up 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -6
- data/lib/rally_up/partner/organization.rb +8 -0
- data/lib/rally_up/partner/token.rb +16 -6
- data/lib/rally_up/partner.rb +6 -2
- data/lib/rally_up/version.rb +1 -1
- data/lib/rally_up.rb +10 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3af27f2c73bd8b33e59476c4e60c0bfd64da1dfcc9dc48d05f573007af284bad
|
4
|
+
data.tar.gz: dd70a7fbe5961f2eda21e49e0bf5efc34d5b0a661fc7d059c0bbb5b8295b6c53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5af8383f16203e045444a141f0ae308bab1957efc177e4dc49bfb7d7eb7cc552274887a7be0c676b6f3e75e86c29a9f82849b384bad5646e8afe8b61219723f
|
7
|
+
data.tar.gz: 792b74686ce10f2974c74ed734f66b4ee3c4b864b4c83513eea281fd1607f1fbafe8716f2aca12c186b1d977725a49100d928e3b2b88ba4e81aa307eb1dea374
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rally_up (1.0
|
4
|
+
rally_up (1.1.0)
|
5
5
|
http (~> 4.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -15,7 +15,7 @@ GEM
|
|
15
15
|
diff-lcs (1.4.4)
|
16
16
|
domain_name (0.5.20190701)
|
17
17
|
unf (>= 0.0.5, < 1.0.0)
|
18
|
-
ffi (1.15.
|
18
|
+
ffi (1.15.5)
|
19
19
|
ffi-compiler (1.0.1)
|
20
20
|
ffi (>= 1.0.0)
|
21
21
|
rake
|
@@ -25,7 +25,7 @@ GEM
|
|
25
25
|
http-cookie (~> 1.0)
|
26
26
|
http-form_data (~> 2.2)
|
27
27
|
http-parser (~> 1.2.0)
|
28
|
-
http-cookie (1.0.
|
28
|
+
http-cookie (1.0.5)
|
29
29
|
domain_name (~> 0.5)
|
30
30
|
http-form_data (2.3.0)
|
31
31
|
http-parser (1.2.3)
|
@@ -49,10 +49,10 @@ GEM
|
|
49
49
|
rspec-mocks (3.10.2)
|
50
50
|
diff-lcs (>= 1.2.0, < 2.0)
|
51
51
|
rspec-support (~> 3.10.0)
|
52
|
-
rspec-support (3.10.
|
52
|
+
rspec-support (3.10.3)
|
53
53
|
unf (0.1.4)
|
54
54
|
unf_ext
|
55
|
-
unf_ext (0.0.8)
|
55
|
+
unf_ext (0.0.8.2)
|
56
56
|
webmock (3.14.0)
|
57
57
|
addressable (>= 2.8.0)
|
58
58
|
crack (>= 0.3.2)
|
@@ -70,4 +70,4 @@ DEPENDENCIES
|
|
70
70
|
webmock
|
71
71
|
|
72
72
|
BUNDLED WITH
|
73
|
-
2.2.
|
73
|
+
2.2.30
|
@@ -68,6 +68,14 @@ module RallyUp
|
|
68
68
|
json = RallyUp::Partner.json(:get, "/v1/partnerapi/organizations/#{id}")
|
69
69
|
new(json[:Result].to_h)
|
70
70
|
end
|
71
|
+
|
72
|
+
def set_on_behalf_of(id:, on_behalf_of:)
|
73
|
+
RallyUp::Partner.request(:post, '/v1/partnerapi/setonbehalfaccount', params: {
|
74
|
+
OrganizationId: id,
|
75
|
+
StripeOnBehalfAccountId: on_behalf_of
|
76
|
+
})
|
77
|
+
new(Id: id).to_h
|
78
|
+
end
|
71
79
|
end
|
72
80
|
end
|
73
81
|
end
|
@@ -15,17 +15,27 @@ module RallyUp
|
|
15
15
|
@expires = json[:'.expires']
|
16
16
|
end
|
17
17
|
|
18
|
+
def expired?
|
19
|
+
expires.nil? || Time.parse(expires).utc < Time.now.utc
|
20
|
+
end
|
21
|
+
|
18
22
|
class << self
|
19
23
|
def retrieve(set: true)
|
20
|
-
json =
|
21
|
-
grant_type: 'password',
|
22
|
-
username: RallyUp::Partner.login,
|
23
|
-
password: RallyUp::Partner.secret
|
24
|
-
})
|
24
|
+
json = JSON.parse(access_token_response, symbolize_names: true)
|
25
25
|
token = new(json)
|
26
|
-
RallyUp::Partner.token = token
|
26
|
+
RallyUp::Partner.token = token if set
|
27
27
|
token
|
28
28
|
end
|
29
|
+
|
30
|
+
def access_token_response
|
31
|
+
params = {
|
32
|
+
grant_type: 'password',
|
33
|
+
username: RallyUp::Partner.login,
|
34
|
+
password: RallyUp::Partner.secret
|
35
|
+
}
|
36
|
+
HTTP.post("https://#{RallyUp::Partner.domain}/v1/partnertoken", body: URI.encode_www_form(params))
|
37
|
+
.body.to_s
|
38
|
+
end
|
29
39
|
end
|
30
40
|
end
|
31
41
|
end
|
data/lib/rally_up/partner.rb
CHANGED
@@ -8,7 +8,7 @@ module RallyUp
|
|
8
8
|
attr_accessor :login, :secret, :domain, :token
|
9
9
|
|
10
10
|
def request(method, path, domain: RallyUp::Partner.domain, params: {}, headers: {})
|
11
|
-
|
11
|
+
set_token if RallyUp::Partner.token.nil? || RallyUp::Partner.token.expired?
|
12
12
|
|
13
13
|
super(
|
14
14
|
method,
|
@@ -16,11 +16,15 @@ module RallyUp
|
|
16
16
|
domain: domain,
|
17
17
|
params: params,
|
18
18
|
headers: headers.merge(
|
19
|
-
'Authorization' => "Bearer #{RallyUp::Partner.token}",
|
19
|
+
'Authorization' => "Bearer #{RallyUp::Partner.token.access_token}",
|
20
20
|
'Content-Type' => 'application/x-www-form-urlencoded'
|
21
21
|
)
|
22
22
|
)
|
23
23
|
end
|
24
|
+
|
25
|
+
def set_token
|
26
|
+
RallyUp::Partner::Token.retrieve(set: true)
|
27
|
+
end
|
24
28
|
end
|
25
29
|
end
|
26
30
|
end
|
data/lib/rally_up/version.rb
CHANGED
data/lib/rally_up.rb
CHANGED
@@ -44,7 +44,7 @@ module RallyUp
|
|
44
44
|
protected
|
45
45
|
|
46
46
|
def verify!(response)
|
47
|
-
return if response.code.to_i
|
47
|
+
return if [200, 201].include?(response.code.to_i)
|
48
48
|
|
49
49
|
raise Error, response
|
50
50
|
end
|
@@ -56,11 +56,20 @@ module RallyUp
|
|
56
56
|
def initialize(response)
|
57
57
|
@body = response.body
|
58
58
|
@code = response.code
|
59
|
+
super
|
59
60
|
end
|
60
61
|
|
61
62
|
def message
|
62
63
|
"#{code} #{body}"
|
63
64
|
end
|
65
|
+
|
66
|
+
def as_json
|
67
|
+
{ error: to_s }
|
68
|
+
end
|
69
|
+
|
70
|
+
def to_s
|
71
|
+
"#{self.class}: #{message}"
|
72
|
+
end
|
64
73
|
end
|
65
74
|
end
|
66
75
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rally_up
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Richey
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
|
-
rubygems_version: 3.
|
118
|
+
rubygems_version: 3.2.15
|
119
119
|
signing_key:
|
120
120
|
specification_version: 4
|
121
121
|
summary: RallyUp API & Partner API ruby gem
|