arux_app 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{arux_app.gemspec → arux.app.gemspec} +1 -1
- data/lib/arux_app/api/account.rb +10 -16
- data/lib/arux_app/api/auth.rb +67 -13
- data/lib/arux_app/api/bank_info.rb +2 -2
- data/lib/arux_app/api/cart.rb +4 -4
- data/lib/arux_app/api/config.rb +3 -3
- data/lib/arux_app/api/student.rb +2 -2
- data/lib/arux_app/api.rb +33 -8
- data/lib/arux_app.rb +4 -4
- 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: 8e67102cdef4d9e36a67d02867cf51bcce88d71135e629b08a3a8aa10e45700b
|
4
|
+
data.tar.gz: 591f4ab4d415cf18ef2354bdc36e957e819c6acc276f2d7d52956b539b315695
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8cf881c14802a6056d42e11cce44b6090bbb8b47f335c0a56fa6499425bad61f8441d174c0f47a4a4e2a565ef71dd363bc292455cb13c3587a8416e9d11f265
|
7
|
+
data.tar.gz: 770187f083bb7bcf481c61ce89af477bdde85bf7720adba6e87820a3e6c52dec52ddb600b03d4c519ff3785a370e7d4bb780d2029b40b79542bd381fb3ccf877
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "arux_app"
|
7
|
-
spec.version = "
|
7
|
+
spec.version = "2.0.0"
|
8
8
|
spec.authors = ["Arux Software"]
|
9
9
|
spec.email = ["sheuer@aruxsoftware.com"]
|
10
10
|
spec.summary = "Ruby gem for interacting with the Arux.app Switchboard APIs."
|
data/lib/arux_app/api/account.rb
CHANGED
@@ -2,13 +2,7 @@ module AruxApp
|
|
2
2
|
module API
|
3
3
|
class Account
|
4
4
|
def self.server_uri
|
5
|
-
|
6
|
-
"https://acc.arux.app"
|
7
|
-
elsif AruxApp::API.testmode?
|
8
|
-
"https://acc.arux.blue"
|
9
|
-
elsif AruxApp::API.devmode?
|
10
|
-
"https://acc.#{HOSTNAME}"
|
11
|
-
end
|
5
|
+
AruxApp::API.server_uri
|
12
6
|
end
|
13
7
|
|
14
8
|
attr_accessor :auth, :access_token, :api_version
|
@@ -16,7 +10,7 @@ module AruxApp
|
|
16
10
|
def initialize(options = {})
|
17
11
|
self.auth = options[:auth]
|
18
12
|
self.access_token = options[:access_token]
|
19
|
-
self.api_version = options[:api_version] || 1.
|
13
|
+
self.api_version = options[:api_version] || 1.3
|
20
14
|
|
21
15
|
raise API::InitializerError.new(:auth_or_access_token, "can't be blank") if self.auth.nil? and self.access_token.nil?
|
22
16
|
raise API::InitializerError.new(:auth, "must be of class type AruxApp::API::Auth") if self.auth and !self.auth.is_a?(AruxApp::API::Auth)
|
@@ -39,7 +33,7 @@ module AruxApp
|
|
39
33
|
end
|
40
34
|
|
41
35
|
def get(uuid, params = {})
|
42
|
-
uuid =
|
36
|
+
uuid = AruxApp::API.uri_escape(uuid.to_s)
|
43
37
|
|
44
38
|
request = HTTPI::Request.new
|
45
39
|
request.url = "#{api_route}/users/#{uuid}"
|
@@ -73,7 +67,7 @@ module AruxApp
|
|
73
67
|
end
|
74
68
|
|
75
69
|
def update(uuid, params)
|
76
|
-
uuid =
|
70
|
+
uuid = AruxApp::API.uri_escape(uuid.to_s)
|
77
71
|
|
78
72
|
request = HTTPI::Request.new
|
79
73
|
request.url = "#{api_route}/users/#{uuid}"
|
@@ -92,8 +86,8 @@ module AruxApp
|
|
92
86
|
end
|
93
87
|
|
94
88
|
def merge(uuid1, uuid2)
|
95
|
-
uuid1 =
|
96
|
-
uuid2 =
|
89
|
+
uuid1 = AruxApp::API.uri_escape(uuid1)
|
90
|
+
uuid2 = AruxApp::API.uri_escape(uuid2)
|
97
91
|
|
98
92
|
request = HTTPI::Request.new
|
99
93
|
request.url = "#{api_route}/users/merge/#{uuid1}/#{uuid2}"
|
@@ -109,7 +103,7 @@ module AruxApp
|
|
109
103
|
end
|
110
104
|
|
111
105
|
def delete(uuid)
|
112
|
-
uuid =
|
106
|
+
uuid = AruxApp::API.uri_escape(uuid.to_s)
|
113
107
|
|
114
108
|
request = HTTPI::Request.new
|
115
109
|
request.url = "#{api_route}/users/#{uuid}"
|
@@ -142,7 +136,7 @@ module AruxApp
|
|
142
136
|
end
|
143
137
|
|
144
138
|
def list_user_locks(user_uuid)
|
145
|
-
uuid =
|
139
|
+
uuid = AruxApp::API.uri_escape(user_uuid.to_s)
|
146
140
|
|
147
141
|
request = HTTPI::Request.new
|
148
142
|
request.url = "#{api_route}/users/#{user_uuid}/locks"
|
@@ -158,7 +152,7 @@ module AruxApp
|
|
158
152
|
end
|
159
153
|
|
160
154
|
def add_user_lock(user_uuid, scope, reason = "")
|
161
|
-
uuid =
|
155
|
+
uuid = AruxApp::API.uri_escape(user_uuid.to_s)
|
162
156
|
|
163
157
|
request = HTTPI::Request.new
|
164
158
|
request.url = "#{api_route}/users/#{uuid}/locks"
|
@@ -182,7 +176,7 @@ module AruxApp
|
|
182
176
|
end
|
183
177
|
|
184
178
|
def delete_user_lock(user_uuid, lock_id)
|
185
|
-
uuid =
|
179
|
+
uuid = AruxApp::API.uri_escape(user_uuid.to_s)
|
186
180
|
|
187
181
|
request = HTTPI::Request.new
|
188
182
|
request.url = "#{api_route}/users/#{uuid}/locks/#{lock_id}"
|
data/lib/arux_app/api/auth.rb
CHANGED
@@ -5,11 +5,12 @@ module AruxApp
|
|
5
5
|
class InvalidClientError < API::Error; end
|
6
6
|
|
7
7
|
class AccessToken
|
8
|
-
attr_accessor :token, :auth
|
8
|
+
attr_accessor :token, :auth, :scope
|
9
9
|
|
10
10
|
def initialize(options = {})
|
11
11
|
self.token = options[:token]
|
12
12
|
self.auth = options[:auth]
|
13
|
+
self.scope = options[:scope]
|
13
14
|
|
14
15
|
raise API::InitializerError.new(:token, "can't be blank") if self.token.to_s.empty?
|
15
16
|
raise API::InitializerError.new(:auth, "can't be blank") if self.auth.nil?
|
@@ -26,13 +27,7 @@ module AruxApp
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def self.server_uri
|
29
|
-
|
30
|
-
"https://sso.arux.app"
|
31
|
-
elsif AruxApp::API.testmode?
|
32
|
-
"https://sso.arux.blue"
|
33
|
-
elsif AruxApp::API.devmode?
|
34
|
-
"https://sso.#{HOSTNAME}"
|
35
|
-
end
|
30
|
+
AruxApp::API.server_uri
|
36
31
|
end
|
37
32
|
|
38
33
|
attr_accessor :client_id, :client_secret, :redirect_uri, :js_callback, :district_subdomain, :current_user_uuid, :login_mechanism, :element
|
@@ -52,12 +47,46 @@ module AruxApp
|
|
52
47
|
raise API::InitializerError.new(:redirect_uri, "can't be blank") if self.redirect_uri.to_s.empty?
|
53
48
|
end
|
54
49
|
|
55
|
-
def authorization_url
|
56
|
-
|
50
|
+
def authorization_url(scope: "public")
|
51
|
+
base_uri = URI.parse("#{self.class.server_uri}/oauth/authorize")
|
52
|
+
params = {
|
53
|
+
scope: scope,
|
54
|
+
response_type: "code",
|
55
|
+
client_id: client_id,
|
56
|
+
redirect_uri: redirect_uri,
|
57
|
+
district: district_subdomain
|
58
|
+
}
|
59
|
+
base_uri.query = URI.encode_www_form(params)
|
60
|
+
base_uri.to_s
|
61
|
+
end
|
62
|
+
|
63
|
+
def basic_authentication(username, password, scope = "public")
|
64
|
+
params = {
|
65
|
+
scope: scope,
|
66
|
+
grant_type: "password",
|
67
|
+
client_id: client_id,
|
68
|
+
client_secret: client_secret
|
69
|
+
}
|
70
|
+
|
71
|
+
request = HTTPI::Request.new.tap do |req|
|
72
|
+
req.url = "#{self.class.server_uri}/oauth/token"
|
73
|
+
req.body = params
|
74
|
+
req.headers = { 'User-Agent' => USER_AGENT }
|
75
|
+
req.auth.basic(username, password)
|
76
|
+
end
|
77
|
+
|
78
|
+
response = HTTPI.post(request)
|
79
|
+
raise(API::Error.new(response.code, response.body)) if response.error?
|
80
|
+
|
81
|
+
AccessToken.new(
|
82
|
+
token: JSON.parse(response.body)['access_token'],
|
83
|
+
scope: JSON.parse(response.body)['scope'],
|
84
|
+
auth: self
|
85
|
+
)
|
57
86
|
end
|
58
87
|
|
59
88
|
def registration_url
|
60
|
-
%(#{self.class.server_uri}/
|
89
|
+
%(#{self.class.server_uri}/users/registrations?client_id=#{self.client_id}&redirect_uri=#{self.redirect_uri}&district=#{self.district_subdomain})
|
61
90
|
end
|
62
91
|
|
63
92
|
def access_token(code)
|
@@ -70,14 +99,18 @@ module AruxApp
|
|
70
99
|
}
|
71
100
|
|
72
101
|
request = HTTPI::Request.new
|
73
|
-
request.url = "#{self.class.server_uri}/
|
102
|
+
request.url = "#{self.class.server_uri}/oauth/token"
|
74
103
|
request.body = data
|
75
104
|
request.headers = {'User-Agent' => USER_AGENT}
|
76
105
|
|
77
106
|
response = HTTPI.post(request)
|
78
107
|
|
79
108
|
if !response.error?
|
80
|
-
|
109
|
+
AccessToken.new(
|
110
|
+
token: JSON.parse(response.body)['access_token'],
|
111
|
+
scope: JSON.parse(response.body)['scope'],
|
112
|
+
auth: self
|
113
|
+
)
|
81
114
|
else
|
82
115
|
begin
|
83
116
|
resp_data = JSON.parse(response.body)
|
@@ -93,6 +126,27 @@ module AruxApp
|
|
93
126
|
end
|
94
127
|
end
|
95
128
|
|
129
|
+
def client_credentials_token
|
130
|
+
data = {
|
131
|
+
scope: "public",
|
132
|
+
grant_type: "client_credentials",
|
133
|
+
client_id: client_id,
|
134
|
+
client_secret: client_secret
|
135
|
+
}
|
136
|
+
|
137
|
+
request = HTTPI::Request.new
|
138
|
+
request.url = "#{self.class.server_uri}/oauth/token"
|
139
|
+
request.body = data
|
140
|
+
request.headers = {'User-Agent' => USER_AGENT}
|
141
|
+
|
142
|
+
response = HTTPI.post(request)
|
143
|
+
if !response.error?
|
144
|
+
AccessToken.new(:token => JSON.parse(response.body)['access_token'], auth: self)
|
145
|
+
else
|
146
|
+
raise(API::Error.new(response.code, response.body))
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
96
150
|
def javascript
|
97
151
|
options = {
|
98
152
|
district: self.district_subdomain,
|
@@ -6,14 +6,14 @@ module AruxApp
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def get(routing_number)
|
9
|
-
routing_number =
|
9
|
+
routing_number = AruxApp::API.uri_escape(routing_number.to_s)
|
10
10
|
|
11
11
|
request = HTTPI::Request.new
|
12
12
|
request.url = "#{self.class.server_uri}/#{routing_number}"
|
13
13
|
request.headers = {'User-Agent' => USER_AGENT}
|
14
14
|
|
15
15
|
response = HTTPI.get(request)
|
16
|
-
|
16
|
+
|
17
17
|
if !response.error?
|
18
18
|
JSON.parse(response.body)
|
19
19
|
else
|
data/lib/arux_app/api/cart.rb
CHANGED
@@ -23,7 +23,7 @@ module AruxApp
|
|
23
23
|
|
24
24
|
def get(uuid = nil)
|
25
25
|
if uuid
|
26
|
-
path = %(/api/#{
|
26
|
+
path = %(/api/#{AruxApp::API.uri_escape(uuid)})
|
27
27
|
else
|
28
28
|
path = %(/api/#{self.generate_cart_path})
|
29
29
|
end
|
@@ -110,7 +110,7 @@ module AruxApp
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def update_item(item_identifier, params)
|
113
|
-
path = %(/api/#{self.generate_cart_path}/items/#{
|
113
|
+
path = %(/api/#{self.generate_cart_path}/items/#{AruxApp::API.uri_escape(item_identifier)})
|
114
114
|
|
115
115
|
request = HTTPI::Request.new
|
116
116
|
request.url = "#{self.class.server_uri}#{path}"
|
@@ -130,7 +130,7 @@ module AruxApp
|
|
130
130
|
end
|
131
131
|
|
132
132
|
def delete_item(item_identifier)
|
133
|
-
path = %(/api/#{self.generate_cart_path}/items/#{
|
133
|
+
path = %(/api/#{self.generate_cart_path}/items/#{AruxApp::API.uri_escape(item_identifier)})
|
134
134
|
|
135
135
|
request = HTTPI::Request.new
|
136
136
|
request.url = "#{self.class.server_uri}#{path}"
|
@@ -179,7 +179,7 @@ module AruxApp
|
|
179
179
|
protected
|
180
180
|
|
181
181
|
def generate_cart_path
|
182
|
-
%(#{
|
182
|
+
%(#{AruxApp::API.uri_escape(self.auth.district_subdomain)}/#{AruxApp::API.uri_escape(self.access_token.token)})
|
183
183
|
end
|
184
184
|
|
185
185
|
def generate_headers
|
data/lib/arux_app/api/config.rb
CHANGED
@@ -21,7 +21,7 @@ module AruxApp
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def get(subdomain_or_sn)
|
24
|
-
subdomain_or_sn =
|
24
|
+
subdomain_or_sn = AruxApp::API.uri_escape(subdomain_or_sn.to_s)
|
25
25
|
|
26
26
|
request = HTTPI::Request.new
|
27
27
|
request.url = "#{self.class.server_uri}/v1/customers/#{subdomain_or_sn}"
|
@@ -37,8 +37,8 @@ module AruxApp
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def get_by(key, value)
|
40
|
-
key =
|
41
|
-
value =
|
40
|
+
key = AruxApp::API.uri_escape(key.to_s)
|
41
|
+
value = AruxApp::API.uri_escape(value.to_s)
|
42
42
|
|
43
43
|
request = HTTPI::Request.new
|
44
44
|
request.url = "#{self.class.server_uri}/v1/customers/by/#{key}/#{value}"
|
data/lib/arux_app/api/student.rb
CHANGED
@@ -7,7 +7,7 @@ module AruxApp
|
|
7
7
|
# firstname & lastname & birthdate
|
8
8
|
# state_student_id
|
9
9
|
request = HTTPI::Request.new
|
10
|
-
request.url = "#{self.class.server_uri}/api/v1/students/lookup/district_student_id/#{
|
10
|
+
request.url = "#{self.class.server_uri}/api/v1/students/lookup/district_student_id/#{AruxApp::API.uri_escape(self.auth.district_subdomain)}"
|
11
11
|
request.query = params
|
12
12
|
request.headers = self.generate_headers
|
13
13
|
|
@@ -25,7 +25,7 @@ module AruxApp
|
|
25
25
|
# firstname & lastname & birthdate
|
26
26
|
# district_student_id
|
27
27
|
request = HTTPI::Request.new
|
28
|
-
request.url = "#{self.class.server_uri}/api/v1/students/lookup/state_student_id/#{
|
28
|
+
request.url = "#{self.class.server_uri}/api/v1/students/lookup/state_student_id/#{AruxApp::API.uri_escape(self.auth.district_subdomain)}"
|
29
29
|
request.query = params
|
30
30
|
request.headers = self.generate_headers
|
31
31
|
|
data/lib/arux_app/api.rb
CHANGED
@@ -6,17 +6,42 @@ module AruxApp
|
|
6
6
|
define_method("#{m}mode?") do
|
7
7
|
@@mode == m
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
define_method("#{m}mode") do
|
11
11
|
@@mode == m
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
define_method("#{m}mode=") do |b|
|
15
15
|
@@mode = b ? m : :standard
|
16
16
|
end
|
17
17
|
end
|
18
|
+
|
19
|
+
def server_uri
|
20
|
+
if AruxApp::API.standardmode?
|
21
|
+
"https://account.arux.app"
|
22
|
+
elsif AruxApp::API.testmode?
|
23
|
+
"https://account.arux.blue"
|
24
|
+
elsif AruxApp::API.devmode?
|
25
|
+
"https://account.#{HOSTNAME}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def uri_escape(str)
|
30
|
+
# URI.escape was deprecated and removed in ruby
|
31
|
+
# https://bugs.ruby-lang.org/issues/17309
|
32
|
+
# The alternatives suggested were using URI::DEFAULT_PARSER
|
33
|
+
# and CGI. This will use URI::DEFAULT_PARSER if it is defined and CGI
|
34
|
+
# if not.
|
35
|
+
if URI.respond_to?(:escape)
|
36
|
+
URI.escape(str)
|
37
|
+
elsif defined? URI::DEFAULT_PARSER
|
38
|
+
URI::DEFAULT_PARSER.escape(str)
|
39
|
+
else
|
40
|
+
CGI.escape(str)
|
41
|
+
end
|
42
|
+
end
|
18
43
|
end
|
19
|
-
|
44
|
+
|
20
45
|
class Error < StandardError
|
21
46
|
attr_accessor :http_status_code
|
22
47
|
def initialize(code, message)
|
@@ -25,22 +50,22 @@ module AruxApp
|
|
25
50
|
self.json = JSON.parse(message)
|
26
51
|
rescue
|
27
52
|
end
|
28
|
-
|
53
|
+
|
29
54
|
super "(#{code}) #{message}"
|
30
55
|
end
|
31
56
|
end
|
32
|
-
|
57
|
+
|
33
58
|
class InitializerError < StandardError
|
34
|
-
def initialize(method, message)
|
59
|
+
def initialize(method, message)
|
35
60
|
super "#{method} #{message}"
|
36
61
|
end
|
37
62
|
end
|
38
63
|
|
39
64
|
class RequirementError < StandardError
|
40
|
-
def initialize(method, message)
|
65
|
+
def initialize(method, message)
|
41
66
|
super "#{method} #{message}"
|
42
67
|
end
|
43
68
|
end
|
44
69
|
|
45
70
|
end
|
46
|
-
end
|
71
|
+
end
|
data/lib/arux_app.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'rubygems'
|
2
|
+
require 'httpi'
|
3
|
+
require 'json'
|
4
4
|
|
5
5
|
require "arux_app/api"
|
6
6
|
|
@@ -13,7 +13,7 @@ require "arux_app/api/student"
|
|
13
13
|
require "arux_app/api/cart"
|
14
14
|
|
15
15
|
module AruxApp
|
16
|
-
VERSION = "
|
16
|
+
VERSION = "2.0.0"
|
17
17
|
USER_AGENT = "Arux.app GEM #{VERSION}"
|
18
18
|
end
|
19
19
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arux_app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arux Software
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpi
|
@@ -80,7 +80,7 @@ files:
|
|
80
80
|
- LICENSE.txt
|
81
81
|
- README.md
|
82
82
|
- Rakefile
|
83
|
-
-
|
83
|
+
- arux.app.gemspec
|
84
84
|
- lib/arux_app.rb
|
85
85
|
- lib/arux_app/api.rb
|
86
86
|
- lib/arux_app/api/account.rb
|