Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:lob/lob-ruby
- Loading branch information
Showing
5 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require "lob/resources/resource_base" | ||
|
||
module Lob | ||
module Resources | ||
class BulkIntlVerifications < Lob::Resources::ResourceBase | ||
|
||
undef_method :list, :find, :create, :destroy | ||
|
||
def initialize(config) | ||
super(config) | ||
@endpoint = "bulk/intl_verifications" | ||
end | ||
|
||
def verify(body={}) | ||
request = { | ||
method: :post, | ||
url: endpoint_url, | ||
body: body | ||
} | ||
|
||
submit request | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require "lob/resources/resource_base" | ||
|
||
module Lob | ||
module Resources | ||
class BulkUSVerifications < Lob::Resources::ResourceBase | ||
|
||
undef_method :list, :find, :create, :destroy | ||
|
||
def initialize(config) | ||
super(config) | ||
@endpoint = "bulk/us_verifications" | ||
end | ||
|
||
def verify(body={}, query={}) | ||
request = { | ||
method: :post, | ||
url: endpoint_url, | ||
body: body, | ||
query: query | ||
} | ||
|
||
submit request | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require "spec_helper" | ||
|
||
describe Lob::Resources::BulkIntlVerifications do | ||
|
||
before :each do | ||
@sample_params = { | ||
addresses: [ | ||
{ | ||
primary_line: "123 Test St", | ||
city: "HEARST", | ||
state: "ONTARIO", | ||
postal_code: "P0L1N0", | ||
country: "CA" | ||
} | ||
] | ||
} | ||
end | ||
|
||
subject { Lob::Client.new(api_key: API_KEY) } | ||
|
||
describe "verify" do | ||
it "should verify an international address" do | ||
result = subject.bulk_intl_verifications.verify @sample_params | ||
addresses = result["addresses"] | ||
address = addresses.first | ||
address["recipient"].must_equal("TEST KEYS DO NOT VERIFY ADDRESSES") | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require "spec_helper" | ||
|
||
describe Lob::Resources::BulkUSVerifications do | ||
|
||
before :each do | ||
@sample_params = { | ||
addresses: [ | ||
{ | ||
recipient: "LOB.COM", | ||
primary_line: "185 BERRY ST STE 6600", | ||
city: "SAN FRANCISCO", | ||
state: "CA", | ||
zip_code: "94107" | ||
} | ||
] | ||
} | ||
end | ||
|
||
subject { Lob::Client.new(api_key: API_KEY) } | ||
|
||
describe "verify" do | ||
it "should verify a US address" do | ||
result = subject.bulk_us_verifications.verify @sample_params | ||
addresses = result["addresses"] | ||
address = addresses.first | ||
address["recipient"].must_equal("TEST KEYS DO NOT VERIFY ADDRESSES") | ||
end | ||
|
||
it "should allow 'case' in query params" do | ||
result = subject.bulk_us_verifications.verify @sample_params, {case: "proper"} | ||
addresses = result["addresses"] | ||
address = addresses.first | ||
address["recipient"].must_equal("Test Keys Do Not Verify Addresses") | ||
end | ||
end | ||
|
||
end |