arux_app 2.0.0 → 3.0.1

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
  SHA256:
3
- metadata.gz: 8e67102cdef4d9e36a67d02867cf51bcce88d71135e629b08a3a8aa10e45700b
4
- data.tar.gz: 591f4ab4d415cf18ef2354bdc36e957e819c6acc276f2d7d52956b539b315695
3
+ metadata.gz: 85bcc4d2383ab3ad7c4cca9f53e8fbb2d9ee68dfe57f74fdaa8d1fa131c18765
4
+ data.tar.gz: af59717d95e085489abf6ca4d168f7728778bd7be1140fceb437c4e7345680af
5
5
  SHA512:
6
- metadata.gz: b8cf881c14802a6056d42e11cce44b6090bbb8b47f335c0a56fa6499425bad61f8441d174c0f47a4a4e2a565ef71dd363bc292455cb13c3587a8416e9d11f265
7
- data.tar.gz: 770187f083bb7bcf481c61ce89af477bdde85bf7720adba6e87820a3e6c52dec52ddb600b03d4c519ff3785a370e7d4bb780d2029b40b79542bd381fb3ccf877
6
+ metadata.gz: 40e9a3479f77e03d7b9b380e6fcdcababc48c2dcfc1fe33cee00e14005b948b138f96934189cd8e1becbcef8d0aa71c54a9f57893b3431a145ecfeddf39c5f83
7
+ data.tar.gz: 44cca7dee5a4b84d4bbb550201cecddc932089d7f41c20f9624fda36d4ae4440c3fab817c939315403e1953e7afc6fc0538900b5f5d4cea0ffe1a50ddd38d420
@@ -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 = "2.0.0"
7
+ spec.version = "3.0.1"
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."
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
17
  spec.require_paths = ["lib"]
18
18
 
19
- spec.add_runtime_dependency "httpi", "~> 2.4"
19
+ spec.add_runtime_dependency "httpi", "~> 3.0"
20
20
  spec.add_runtime_dependency "json", ">= 0"
21
21
 
22
22
  spec.add_development_dependency "bundler", ">= 1.14"
@@ -1,10 +1,6 @@
1
1
  module AruxApp
2
2
  module API
3
3
  class Account
4
- def self.server_uri
5
- AruxApp::API.server_uri
6
- end
7
-
8
4
  attr_accessor :auth, :access_token, :api_version
9
5
 
10
6
  def initialize(options = {})
@@ -17,6 +13,22 @@ module AruxApp
17
13
  raise API::InitializerError.new(:access_token, "must be of class type AruxApp::API::Auth::AccessToken") if self.access_token and !self.access_token.is_a?(AruxApp::API::Auth::AccessToken)
18
14
  end
19
15
 
16
+ def self.public_uri
17
+ AruxApp::API.uri(subdomain: "account")
18
+ end
19
+
20
+ def public_uri
21
+ self.class.public_uri
22
+ end
23
+
24
+ def self.api_uri
25
+ AruxApp::API.uri(subdomain: "account.api")
26
+ end
27
+
28
+ def api_uri
29
+ self.class.api_uri
30
+ end
31
+
20
32
  def list(params = {})
21
33
  request = HTTPI::Request.new
22
34
  request.url = "#{api_route}/users"
@@ -135,62 +147,6 @@ module AruxApp
135
147
  end
136
148
  end
137
149
 
138
- def list_user_locks(user_uuid)
139
- uuid = AruxApp::API.uri_escape(user_uuid.to_s)
140
-
141
- request = HTTPI::Request.new
142
- request.url = "#{api_route}/users/#{user_uuid}/locks"
143
- request.headers = self.generate_headers
144
-
145
- response = HTTPI.get(request)
146
-
147
- if !response.error?
148
- JSON.parse(response.body)
149
- else
150
- raise(API::Error.new(response.code, response.body))
151
- end
152
- end
153
-
154
- def add_user_lock(user_uuid, scope, reason = "")
155
- uuid = AruxApp::API.uri_escape(user_uuid.to_s)
156
-
157
- request = HTTPI::Request.new
158
- request.url = "#{api_route}/users/#{uuid}/locks"
159
- request.body = {
160
- user_lock: {
161
- scope: scope,
162
- reason: reason
163
- }
164
- }.to_json
165
- request.headers = self.generate_headers
166
-
167
- response = HTTPI.post(request)
168
-
169
- if response.code == 201
170
- true
171
- elsif !response.error?
172
- JSON.parse(response.body)
173
- else
174
- raise(API::Error.new(response.code, response.body))
175
- end
176
- end
177
-
178
- def delete_user_lock(user_uuid, lock_id)
179
- uuid = AruxApp::API.uri_escape(user_uuid.to_s)
180
-
181
- request = HTTPI::Request.new
182
- request.url = "#{api_route}/users/#{uuid}/locks/#{lock_id}"
183
- request.headers = self.generate_headers
184
-
185
- response = HTTPI.delete(request)
186
-
187
- if !response.error?
188
- JSON.parse(response.body)
189
- else
190
- raise(API::Error.new(response.code, response.body))
191
- end
192
- end
193
-
194
150
  # TODO:: create mapping for relationships api endpoints
195
151
  def list_relationships
196
152
  end
@@ -207,7 +163,7 @@ module AruxApp
207
163
  protected
208
164
 
209
165
  def api_route
210
- "#{self.class.server_uri}/api/v#{api_version}"
166
+ "#{api_uri}/api/v#{api_version}"
211
167
  end
212
168
 
213
169
  def generate_headers
@@ -26,10 +26,6 @@ module AruxApp
26
26
  end
27
27
  end
28
28
 
29
- def self.server_uri
30
- AruxApp::API.server_uri
31
- end
32
-
33
29
  attr_accessor :client_id, :client_secret, :redirect_uri, :js_callback, :district_subdomain, :current_user_uuid, :login_mechanism, :element
34
30
 
35
31
  def initialize(options = {})
@@ -47,8 +43,24 @@ module AruxApp
47
43
  raise API::InitializerError.new(:redirect_uri, "can't be blank") if self.redirect_uri.to_s.empty?
48
44
  end
49
45
 
46
+ def self.public_uri
47
+ AruxApp::API.uri(subdomain: "account")
48
+ end
49
+
50
+ def public_uri
51
+ self.class.public_uri
52
+ end
53
+
54
+ def self.api_uri
55
+ AruxApp::API.uri(subdomain: "account.api")
56
+ end
57
+
58
+ def api_uri
59
+ self.class.api_uri
60
+ end
61
+
50
62
  def authorization_url(scope: "public")
51
- base_uri = URI.parse("#{self.class.server_uri}/oauth/authorize")
63
+ base_uri = URI.parse("#{public_uri}/oauth/authorize")
52
64
  params = {
53
65
  scope: scope,
54
66
  response_type: "code",
@@ -69,7 +81,7 @@ module AruxApp
69
81
  }
70
82
 
71
83
  request = HTTPI::Request.new.tap do |req|
72
- req.url = "#{self.class.server_uri}/oauth/token"
84
+ req.url = "#{public_uri}/oauth/token"
73
85
  req.body = params
74
86
  req.headers = { 'User-Agent' => USER_AGENT }
75
87
  req.auth.basic(username, password)
@@ -86,7 +98,7 @@ module AruxApp
86
98
  end
87
99
 
88
100
  def registration_url
89
- %(#{self.class.server_uri}/users/registrations?client_id=#{self.client_id}&redirect_uri=#{self.redirect_uri}&district=#{self.district_subdomain})
101
+ %(#{public_uri}/users/registrations?client_id=#{self.client_id}&redirect_uri=#{self.redirect_uri}&district=#{self.district_subdomain})
90
102
  end
91
103
 
92
104
  def access_token(code)
@@ -99,7 +111,7 @@ module AruxApp
99
111
  }
100
112
 
101
113
  request = HTTPI::Request.new
102
- request.url = "#{self.class.server_uri}/oauth/token"
114
+ request.url = "#{api_uri}/oauth/token"
103
115
  request.body = data
104
116
  request.headers = {'User-Agent' => USER_AGENT}
105
117
 
@@ -135,7 +147,7 @@ module AruxApp
135
147
  }
136
148
 
137
149
  request = HTTPI::Request.new
138
- request.url = "#{self.class.server_uri}/oauth/token"
150
+ request.url = "#{api_uri}/oauth/token"
139
151
  request.body = data
140
152
  request.headers = {'User-Agent' => USER_AGENT}
141
153
 
@@ -1,15 +1,27 @@
1
1
  module AruxApp
2
2
  module API
3
3
  class BankInfo
4
- def self.server_uri
5
- "https://banks.api.arux.app"
4
+ def self.public_uri
5
+ AruxApp::API.uri(subdomain: "banks")
6
+ end
7
+
8
+ def public_uri
9
+ self.class.public_uri
10
+ end
11
+
12
+ def self.api_uri
13
+ AruxApp::API.uri(subdomain: "banks.api")
14
+ end
15
+
16
+ def api_uri
17
+ self.class.api_uri
6
18
  end
7
19
 
8
20
  def get(routing_number)
9
21
  routing_number = AruxApp::API.uri_escape(routing_number.to_s)
10
22
 
11
23
  request = HTTPI::Request.new
12
- request.url = "#{self.class.server_uri}/#{routing_number}"
24
+ request.url = "#{api_uri}/#{routing_number}"
13
25
  request.headers = {'User-Agent' => USER_AGENT}
14
26
 
15
27
  response = HTTPI.get(request)
@@ -1,16 +1,6 @@
1
1
  module AruxApp
2
2
  module API
3
3
  class Cart
4
- def self.server_uri
5
- if AruxApp::API.standardmode?
6
- "https://cart.arux.app"
7
- elsif AruxApp::API.testmode?
8
- "https://cart.arux.blue"
9
- elsif AruxApp::API.devmode?
10
- "https://cart.#{HOSTNAME}"
11
- end
12
- end
13
-
14
4
  attr_accessor :auth, :access_token
15
5
 
16
6
  def initialize(options = {})
@@ -21,6 +11,22 @@ module AruxApp
21
11
  raise API::InitializerError.new(:access_token, "must be of class type AruxApp::API::Auth::AccessToken") if !self.access_token.is_a?(AruxApp::API::Auth::AccessToken)
22
12
  end
23
13
 
14
+ def self.public_uri
15
+ AruxApp::API.uri(subdomain: "cart")
16
+ end
17
+
18
+ def public_uri
19
+ self.class.public_uri
20
+ end
21
+
22
+ def self.api_uri
23
+ AruxApp::API.uri(subdomain: "cart.api")
24
+ end
25
+
26
+ def api_uri
27
+ self.class.api_uri
28
+ end
29
+
24
30
  def get(uuid = nil)
25
31
  if uuid
26
32
  path = %(/api/#{AruxApp::API.uri_escape(uuid)})
@@ -29,7 +35,7 @@ module AruxApp
29
35
  end
30
36
 
31
37
  request = HTTPI::Request.new
32
- request.url = "#{self.class.server_uri}#{path}"
38
+ request.url = "#{api_uri}#{path}"
33
39
  request.headers = self.generate_headers
34
40
 
35
41
  response = HTTPI.get(request)
@@ -45,7 +51,7 @@ module AruxApp
45
51
  path = %(/api/#{self.generate_cart_path}/status)
46
52
 
47
53
  request = HTTPI::Request.new
48
- request.url = "#{self.class.server_uri}#{path}"
54
+ request.url = "#{api_uri}#{path}"
49
55
  request.headers = self.generate_headers
50
56
 
51
57
  response = HTTPI.get(request)
@@ -61,7 +67,7 @@ module AruxApp
61
67
  path = %(/api/#{self.generate_cart_path}/items)
62
68
 
63
69
  request = HTTPI::Request.new
64
- request.url = "#{self.class.server_uri}#{path}"
70
+ request.url = "#{api_uri}#{path}"
65
71
  request.headers = self.generate_headers
66
72
 
67
73
  response = HTTPI.get(request)
@@ -77,7 +83,7 @@ module AruxApp
77
83
  path = %(/api/#{self.generate_cart_path}/items/#{item_identifier})
78
84
 
79
85
  request = HTTPI::Request.new
80
- request.url = "#{self.class.server_uri}#{path}"
86
+ request.url = "#{api_uri}#{path}"
81
87
  request.headers = self.generate_headers
82
88
 
83
89
  response = HTTPI.get(request)
@@ -93,7 +99,7 @@ module AruxApp
93
99
  path = %(/api/#{self.generate_cart_path}/items)
94
100
 
95
101
  request = HTTPI::Request.new
96
- request.url = "#{self.class.server_uri}#{path}"
102
+ request.url = "#{api_uri}#{path}"
97
103
  if params.keys.first.to_s != 'item'
98
104
  params = {:item => params}
99
105
  end
@@ -113,7 +119,7 @@ module AruxApp
113
119
  path = %(/api/#{self.generate_cart_path}/items/#{AruxApp::API.uri_escape(item_identifier)})
114
120
 
115
121
  request = HTTPI::Request.new
116
- request.url = "#{self.class.server_uri}#{path}"
122
+ request.url = "#{api_uri}#{path}"
117
123
  if params.keys.first.to_s != 'item'
118
124
  params = {:item => params}
119
125
  end
@@ -133,7 +139,7 @@ module AruxApp
133
139
  path = %(/api/#{self.generate_cart_path}/items/#{AruxApp::API.uri_escape(item_identifier)})
134
140
 
135
141
  request = HTTPI::Request.new
136
- request.url = "#{self.class.server_uri}#{path}"
142
+ request.url = "#{api_uri}#{path}"
137
143
  request.headers = self.generate_headers
138
144
 
139
145
  response = HTTPI.delete(request)
@@ -148,7 +154,7 @@ module AruxApp
148
154
  def destroy(uuid)
149
155
  path = "/api/#{self.generate_cart_path}/carts/#{uuid}"
150
156
  request = HTTPI::Request.new
151
- request.url = "#{self.class.server_uri}#{path}"
157
+ request.url = "#{api_uri}#{path}"
152
158
  request.headers = self.generate_headers
153
159
 
154
160
  response = HTTPI.delete(request)
@@ -163,7 +169,7 @@ module AruxApp
163
169
  def create(params)
164
170
  path = "/api/#{self.generate_cart_path}/carts"
165
171
  request = HTTPI::Request.new
166
- request.url = "#{self.class.server_uri}#{path}"
172
+ request.url = "#{api_uri}#{path}"
167
173
  request.headers = self.generate_headers
168
174
  request.body = params.to_json
169
175
 
@@ -0,0 +1,38 @@
1
+ module AruxApp
2
+ module API
3
+ class Checkout
4
+ API_VERSION = 1
5
+
6
+ def self.public_uri
7
+ AruxApp::API.uri(subdomain: "pay")
8
+ end
9
+
10
+ def public_uri
11
+ self.class.public_uri
12
+ end
13
+
14
+ def self.api_uri
15
+ AruxApp::API.uri(subdomain: "pay.api")
16
+ end
17
+
18
+ def api_uri
19
+ self.class.api_uri
20
+ end
21
+
22
+ def self.api_route
23
+ "#{api_uri}/api/v#{API_VERSION}/"
24
+ end
25
+
26
+ def self.iframe_url
27
+ case AruxApp::API.mode
28
+ when :production
29
+ "https://htp.tokenex.com/Iframe/Iframe-v3.min.js"
30
+ when :staging, :development, :test
31
+ "https://test-htp.tokenex.com/Iframe/Iframe-v3.min.js"
32
+ else
33
+ raise "AruxApp::API environment not supported"
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,16 +1,6 @@
1
1
  module AruxApp
2
2
  module API
3
3
  class Config
4
- def self.server_uri
5
- if AruxApp::API.standardmode?
6
- "https://config.arux.app"
7
- elsif AruxApp::API.testmode?
8
- "https://config.arux.blue"
9
- elsif AruxApp::API.devmode?
10
- "http://config.#{HOSTNAME}"
11
- end
12
- end
13
-
14
4
  attr_accessor :auth
15
5
 
16
6
  def initialize(options = {})
@@ -20,11 +10,27 @@ module AruxApp
20
10
  raise API::InitializerError.new(:auth, "must be of class type AruxApp::API::Auth") if !self.auth.is_a?(AruxApp::API::Auth)
21
11
  end
22
12
 
13
+ def self.public_uri
14
+ AruxApp::API.uri(subdomain: "config")
15
+ end
16
+
17
+ def public_uri
18
+ self.class.public_uri
19
+ end
20
+
21
+ def self.api_uri
22
+ AruxApp::API.uri(subdomain: "config.api")
23
+ end
24
+
25
+ def api_uri
26
+ self.class.api_uri
27
+ end
28
+
23
29
  def get(subdomain_or_sn)
24
30
  subdomain_or_sn = AruxApp::API.uri_escape(subdomain_or_sn.to_s)
25
31
 
26
32
  request = HTTPI::Request.new
27
- request.url = "#{self.class.server_uri}/v1/customers/#{subdomain_or_sn}"
33
+ request.url = "#{api_uri}/v1/customers/#{subdomain_or_sn}"
28
34
  request.headers = self.generate_headers
29
35
 
30
36
  response = HTTPI.get(request)
@@ -41,7 +47,7 @@ module AruxApp
41
47
  value = AruxApp::API.uri_escape(value.to_s)
42
48
 
43
49
  request = HTTPI::Request.new
44
- request.url = "#{self.class.server_uri}/v1/customers/by/#{key}/#{value}"
50
+ request.url = "#{api_uri}/v1/customers/by/#{key}/#{value}"
45
51
  request.headers = self.generate_headers
46
52
 
47
53
  response = HTTPI.get(request)
data/lib/arux_app/api.rb CHANGED
@@ -1,29 +1,27 @@
1
1
  module AruxApp
2
2
  module API
3
- class << self
4
- @@mode = :standard
5
- [:test, :dev, :standard].each do |m|
6
- define_method("#{m}mode?") do
7
- @@mode == m
8
- end
3
+ DOMAINS = {
4
+ production: "arux.app",
5
+ staging: "arux.blue",
6
+ development: HOSTNAME,
7
+ test: "arux.test"
8
+ }
9
9
 
10
- define_method("#{m}mode") do
11
- @@mode == m
12
- end
10
+ class << self
11
+ def mode
12
+ raise "Environment is not set, i.e. ARUX_APP_GEM_MODE = :development" unless const_defined?(:ARUX_APP_GEM_MODE)
13
+ ARUX_APP_GEM_MODE
14
+ end
13
15
 
14
- define_method("#{m}mode=") do |b|
15
- @@mode = b ? m : :standard
16
- end
16
+ def uri(subdomain:)
17
+ URI::HTTPS.build(
18
+ host: [subdomain, domain].join('.'),
19
+ )
17
20
  end
18
21
 
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
22
+ def domain
23
+ raise "#{mode} is not a supported environment" unless DOMAINS.has_key?(mode)
24
+ DOMAINS[mode]
27
25
  end
28
26
 
29
27
  def uri_escape(str)
data/lib/arux_app.rb CHANGED
@@ -1,34 +1,23 @@
1
- require 'rubygems'
2
- require 'httpi'
3
- require 'json'
1
+ HOSTNAME = if ENV.has_key?("DEV_HOST")
2
+ ENV.fetch("DEV_HOST")
3
+ elsif RUBY_PLATFORM =~ /darwin/
4
+ "#{`scutil --get LocalHostName`.downcase.strip}.local"
5
+ else
6
+ `hostname`.downcase.strip
7
+ end
4
8
 
9
+ require "rubygems"
10
+ require "httpi"
11
+ require "json"
5
12
  require "arux_app/api"
6
-
13
+ require "arux_app/api/checkout"
7
14
  require "arux_app/api/bank_info"
8
15
  require "arux_app/api/config"
9
16
  require "arux_app/api/auth"
10
- require "arux_app/api/nav"
11
17
  require "arux_app/api/account"
12
- require "arux_app/api/student"
13
18
  require "arux_app/api/cart"
14
19
 
15
20
  module AruxApp
16
- VERSION = "2.0.0"
21
+ VERSION = "3.0.1"
17
22
  USER_AGENT = "Arux.app GEM #{VERSION}"
18
23
  end
19
-
20
- if ENV['ARUX_APP_GEM_TEST_MODE'].to_s == "true"
21
- AruxApp::API.testmode = true
22
- end
23
-
24
- if ENV['ARUX_APP_GEM_DEV_MODE'].to_s == "true"
25
- AruxApp::API.devmode = true
26
- end
27
-
28
- if ENV.has_key?("DEV_HOST")
29
- HOSTNAME = ENV.fetch("DEV_HOST")
30
- elsif RUBY_PLATFORM =~ /darwin/
31
- HOSTNAME = "#{`scutil --get LocalHostName`.downcase.strip}.local"
32
- else
33
- HOSTNAME = `hostname`.downcase.strip
34
- end
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: 2.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arux Software
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-21 00:00:00.000000000 Z
11
+ date: 2024-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpi
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.4'
19
+ version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.4'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -80,16 +80,15 @@ files:
80
80
  - LICENSE.txt
81
81
  - README.md
82
82
  - Rakefile
83
- - arux.app.gemspec
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
87
87
  - lib/arux_app/api/auth.rb
88
88
  - lib/arux_app/api/bank_info.rb
89
89
  - lib/arux_app/api/cart.rb
90
+ - lib/arux_app/api/checkout.rb
90
91
  - lib/arux_app/api/config.rb
91
- - lib/arux_app/api/nav.rb
92
- - lib/arux_app/api/student.rb
93
92
  homepage: https://arux.software
94
93
  licenses:
95
94
  - MIT
@@ -1,29 +0,0 @@
1
- module AruxApp
2
- module API
3
- class Nav
4
-
5
- attr_accessor :auth
6
-
7
- def initialize(options = {})
8
- self.auth = options[:auth]
9
-
10
- raise API::InitializerError.new(:auth, "can't be blank") if self.auth.nil?
11
- raise API::InitializerError.new(:auth, "must be of class type AruxApp::API::Auth") if !self.auth.is_a?(AruxApp::API::Auth)
12
- end
13
-
14
- def javascript
15
- options = {
16
- district: self.auth.district_subdomain,
17
- login: {
18
- current_uuid: self.auth.current_user_uuid,
19
- client_id: self.auth.client_id,
20
- redirect_uri: self.auth.redirect_uri,
21
- callback: self.auth.js_callback
22
- }
23
- }
24
- return %(new SwitchBoardIONav(#{options.to_json});)
25
- end
26
-
27
- end
28
- end
29
- end
@@ -1,43 +0,0 @@
1
- module AruxApp
2
- module API
3
- class Student < Account
4
-
5
- def lookup_district_student_id(params)
6
- # accepted lookup attributes
7
- # firstname & lastname & birthdate
8
- # state_student_id
9
- request = HTTPI::Request.new
10
- request.url = "#{self.class.server_uri}/api/v1/students/lookup/district_student_id/#{AruxApp::API.uri_escape(self.auth.district_subdomain)}"
11
- request.query = params
12
- request.headers = self.generate_headers
13
-
14
- response = HTTPI.get(request)
15
-
16
- if !response.error?
17
- JSON.parse(response.body)
18
- else
19
- raise(API::Error.new(response.code, response.body))
20
- end
21
- end
22
-
23
- def lookup_state_student_id(params)
24
- # accepted lookup attributes
25
- # firstname & lastname & birthdate
26
- # district_student_id
27
- request = HTTPI::Request.new
28
- request.url = "#{self.class.server_uri}/api/v1/students/lookup/state_student_id/#{AruxApp::API.uri_escape(self.auth.district_subdomain)}"
29
- request.query = params
30
- request.headers = self.generate_headers
31
-
32
- response = HTTPI.get(request)
33
-
34
- if !response.error?
35
- JSON.parse(response.body)
36
- else
37
- raise(API::Error.new(response.code, response.body))
38
- end
39
- end
40
-
41
- end
42
- end
43
- end