Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:consolo/ability_client

  • Loading branch information...
commit 43831d2d06307d20b288ecd2b0cbe56a3314f767 2 parents 85cbf6c + 2776475
@penguincoder penguincoder authored
View
4 lib/ability/change_password.rb
@@ -12,8 +12,8 @@ def initialize(user, password, service_id, new_password, opts)
@opts = opts
end
- def endpoint
- "https://access.abilitynetwork.com/portal/seapi/services/PasswordChange/#{service_id}"
+ def resource_name
+ "PasswordChange"
end
def xml
View
4 lib/ability/claim_inquiry.rb
@@ -23,8 +23,8 @@ def initialize(user, password, service_id, opts)
@opts = opts
end
- def endpoint
- "https://access.abilitynetwork.com/portal/seapi/services/DDEClaimInquiry/#{service_id}"
+ def resource_name
+ "DDEClaimInquiry"
end
def xml
View
4 lib/ability/claim_status_inquiry.rb
@@ -12,8 +12,8 @@ def initialize(user, password, service_id, opts)
@opts = opts
end
- def endpoint
- "https://access.abilitynetwork.com/portal/seapi/services/PPTNClaimStatusInquiry/#{service_id}"
+ def resource_name
+ "PPTNClaimStatusInquiry"
end
def xml
View
17 lib/ability/client.rb
@@ -7,6 +7,7 @@ class Ability::Client
include Ability::Helpers::XmlHelpers
SEAPI_VERSION = 1
+ API_ROOT = "https://access.abilitynetwork.com/portal/seapi/services"
attr_accessor :user,
:password,
@@ -36,7 +37,7 @@ def initialize(username, password, opts = nil)
# Returns a list of services.
def services
request = Ability::ServiceList::Request.new
- response = Ability::ServiceList::Response.new(xml(get(request.endpoint)))
+ response = Ability::ServiceList::Response.new(xml(get(API_ROOT)))
response.parsed
end
@@ -44,7 +45,7 @@ def services
def claim_inquiry(service_id, *args)
opts = args_to_hash(*args)
request = Ability::ClaimInquiry::Request.new(user, password, service_id, opts)
- doc = xml(post(request.endpoint, request.xml))
+ doc = xml(post(endpoint(request), request.xml))
response = Ability::ClaimInquiry::Response.new(doc, opts)
response.parsed
end
@@ -53,7 +54,7 @@ def claim_inquiry(service_id, *args)
def eligibility_inquiry(service_id, *args)
opts = args_to_hash(*args)
request = Ability::EligibilityInquiry::Request.new(user, password, service_id, opts)
- doc = xml(post(request.endpoint, request.xml))
+ doc = xml(post(endpoint(request), request.xml))
response = Ability::EligibilityInquiry::Response.new(doc, opts)
response.parsed
end
@@ -62,7 +63,7 @@ def eligibility_inquiry(service_id, *args)
def claim_status_inquiry(service_id, *args)
opts = args_to_hash(*args)
request = Ability::ClaimStatusInquiry::Request.new(user, password, service_id, opts)
- doc = xml(post(request.endpoint, request.xml))
+ doc = xml(post(endpoint(request), request.xml))
response = Ability::ClaimStatusInquiry::Response.new(doc, opts)
response.parsed
end
@@ -70,14 +71,14 @@ def claim_status_inquiry(service_id, *args)
# Generate a password
def generate_password(service_id)
request = Ability::PasswordGenerate::Request.new(service_id)
- post(request.endpoint)
+ post(endpoint(request))
end
# Change a password or clerk password
def change_password(service_id, new_password, *args)
opts = args_to_hash(*args)
request = Ability::ChangePassword::Request.new(user, password, service_id, new_password, opts)
- post(request.endpoint, request.xml)
+ post(endpoint(request), request.xml)
# Change client password unless clerk password is being changed
@password = new_password unless opts[:clerk]
@@ -85,6 +86,10 @@ def change_password(service_id, new_password, *args)
private
+ def endpoint(request)
+ "#{API_ROOT}/#{request.resource_name}/#{request.service_id}"
+ end
+
def xml(raw)
REXML::Document.new(raw)
end
View
4 lib/ability/eligibility_inquiry.rb
@@ -11,8 +11,8 @@ def initialize(user, password, service_id, opts)
@opts = opts
end
- def endpoint
- "https://access.abilitynetwork.com/portal/seapi/services/DDEEligibilityInquiry/#{service_id}"
+ def resource_name
+ "DDEEligibilityInquiry"
end
def xml
View
4 lib/ability/password_generate.rb
@@ -7,8 +7,8 @@ def initialize(service_id)
@service_id = service_id
end
- def endpoint
- "https://access.abilitynetwork.com/portal/seapi/services/PasswordGenerate/#{service_id}"
+ def resource_name
+ "PasswordGenerate"
end
end
end
View
3  lib/ability/request.rb
@@ -1,6 +1,5 @@
module Ability
class Request
- def initialize
- end
+ def initialize; end
end
end
View
2  test/unit/client_test.rb
@@ -35,7 +35,7 @@ def test_services
end
def test_claim_inquiry
- claim_endpoint = "https://www.abilitynetwork.com/portal/seapi/services/DDEClaimInquiry/#{@service_id}"
+ claim_endpoint = "https://access.abilitynetwork.com/portal/seapi/services/DDEClaimInquiry/#{@service_id}"
stub_request(:post, claim_endpoint).with(:body => request_xml(:claim_inquiry)).to_return(:body => response_xml(:claim_inquiry))
assert_equal([
Please sign in to comment.
Something went wrong with that request. Please try again.