Skip to content

Commit

Permalink
API Updates (#979)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardm-stripe authored May 19, 2021
1 parent ca8a367 commit 0ba9307
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ notifications:
env:
global:
# If changing this number, please also change it in `test/test_helper.rb`.
- STRIPE_MOCK_VERSION=0.103.0
- STRIPE_MOCK_VERSION=0.105.0

cache:
directories:
Expand Down
2 changes: 2 additions & 0 deletions lib/stripe/object_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def self.object_names_to_classes
File::OBJECT_NAME => File,
File::OBJECT_NAME_ALT => File,
FileLink::OBJECT_NAME => FileLink,
Identity::VerificationReport::OBJECT_NAME => Identity::VerificationReport,
Identity::VerificationSession::OBJECT_NAME => Identity::VerificationSession,
Invoice::OBJECT_NAME => Invoice,
InvoiceItem::OBJECT_NAME => InvoiceItem,
InvoiceLineItem::OBJECT_NAME => InvoiceLineItem,
Expand Down
2 changes: 2 additions & 0 deletions lib/stripe/resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
require "stripe/resources/exchange_rate"
require "stripe/resources/file"
require "stripe/resources/file_link"
require "stripe/resources/identity/verification_report"
require "stripe/resources/identity/verification_session"
require "stripe/resources/invoice"
require "stripe/resources/invoice_item"
require "stripe/resources/invoice_line_item"
Expand Down
12 changes: 12 additions & 0 deletions lib/stripe/resources/identity/verification_report.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# File generated from our OpenAPI spec
# frozen_string_literal: true

module Stripe
module Identity
class VerificationReport < APIResource
extend Stripe::APIOperations::List

OBJECT_NAME = "identity.verification_report"
end
end
end
35 changes: 35 additions & 0 deletions lib/stripe/resources/identity/verification_session.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# File generated from our OpenAPI spec
# frozen_string_literal: true

module Stripe
module Identity
class VerificationSession < APIResource
extend Stripe::APIOperations::Create
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save

OBJECT_NAME = "identity.verification_session"

custom_method :cancel, http_verb: :post
custom_method :redact, http_verb: :post

def cancel(params = {}, opts = {})
request_stripe_object(
method: :post,
path: resource_url + "/cancel",
params: params,
opts: opts
)
end

def redact(params = {}, opts = {})
request_stripe_object(
method: :post,
path: resource_url + "/redact",
params: params,
opts: opts
)
end
end
end
end
22 changes: 22 additions & 0 deletions test/stripe/identity/verification_report_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

require ::File.expand_path("../../test_helper", __dir__)

module Stripe
module Identity
class VerificationReportTest < Test::Unit::TestCase
should "be listable" do
verification_reports = Stripe::Identity::VerificationReport.list
assert_requested :get, "#{Stripe.api_base}/v1/identity/verification_reports"
assert verification_reports.data.is_a?(Array)
assert verification_reports.data[0].is_a?(Stripe::Identity::VerificationReport)
end

should "be retrievable" do
verification_report = Stripe::Identity::VerificationReport.retrieve("vs_123")
assert_requested :get, "#{Stripe.api_base}/v1/identity/verification_reports/vs_123"
assert verification_report.is_a?(Stripe::Identity::VerificationReport)
end
end
end
end
72 changes: 72 additions & 0 deletions test/stripe/identity/verification_session_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# frozen_string_literal: true

require ::File.expand_path("../../test_helper", __dir__)

module Stripe
module Identity
class VerificationSessionTest < Test::Unit::TestCase
should "be listable" do
verification_sessions = Stripe::Identity::VerificationSession.list
assert_requested :get, "#{Stripe.api_base}/v1/identity/verification_sessions"
assert verification_sessions.data.is_a?(Array)
assert verification_sessions.data[0].is_a?(Stripe::Identity::VerificationSession)
end

should "be retrievable" do
verification_session = Stripe::Identity::VerificationSession.retrieve("vs_123")
assert_requested :get, "#{Stripe.api_base}/v1/identity/verification_sessions/vs_123"
assert verification_session.is_a?(Stripe::Identity::VerificationSession)
end

should "be saveable" do
verification_session = Stripe::Identity::VerificationSession.retrieve("vs_123")
verification_session.metadata["key"] = "value"
verification_session.save
assert_requested :post, "#{Stripe.api_base}/v1/identity/verification_sessions/#{verification_session.id}"
assert verification_session.is_a?(Stripe::Identity::VerificationSession)
end

should "be updateable" do
verification_session = Stripe::Identity::VerificationSession.update("vs_123", metadata: { foo: "bar" })
assert_requested :post, "#{Stripe.api_base}/v1/identity/verification_sessions/vs_123"
assert verification_session.is_a?(Stripe::Identity::VerificationSession)
end

context ".cancel" do
should "cancel an verification_session" do
payment_intent = Stripe::Identity::VerificationSession.cancel("vs_123")

assert_requested :post, "#{Stripe.api_base}/v1/identity/verification_sessions/vs_123/cancel"
assert payment_intent.is_a?(Stripe::Identity::VerificationSession)
end
end

context "#cancel" do
should "cancel an verification_session" do
verification_session = Stripe::Identity::VerificationSession.retrieve("vs_123")
verification_session.cancel
assert_requested :post, "#{Stripe.api_base}/v1/identity/verification_sessions/vs_123/cancel"
assert verification_session.is_a?(Stripe::Identity::VerificationSession)
end
end

context ".redact" do
should "redact an verification_session" do
payment_intent = Stripe::Identity::VerificationSession.redact("vs_123")

assert_requested :post, "#{Stripe.api_base}/v1/identity/verification_sessions/vs_123/redact"
assert payment_intent.is_a?(Stripe::Identity::VerificationSession)
end
end

context "#redact" do
should "redact an verification_session" do
verification_session = Stripe::Identity::VerificationSession.retrieve("vs_123")
verification_session.redact
assert_requested :post, "#{Stripe.api_base}/v1/identity/verification_sessions/vs_123/redact"
assert verification_session.is_a?(Stripe::Identity::VerificationSession)
end
end
end
end
end
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
require ::File.expand_path("stripe_mock", __dir__)

# If changing this number, please also change it in `.travis.yml`.
MOCK_MINIMUM_VERSION = "0.103.0"
MOCK_MINIMUM_VERSION = "0.105.0"
MOCK_PORT = Stripe::StripeMock.start

# Disable all real network connections except those that are outgoing to
Expand Down

0 comments on commit 0ba9307

Please sign in to comment.