Adds support for login links

This commit is contained in:
Olivier Bellone 2017-05-19 17:22:54 +02:00
parent f87e1ed219
commit 330763aa02
4 changed files with 38 additions and 0 deletions

View File

@ -52,6 +52,7 @@ require 'stripe/file_upload'
require 'stripe/invoice'
require 'stripe/invoice_item'
require 'stripe/invoice_line_item'
require 'stripe/login_link'
require 'stripe/order'
require 'stripe/order_return'
require 'stripe/payout'

9
lib/stripe/login_link.rb Normal file
View File

@ -0,0 +1,9 @@
module Stripe
class LoginLink < APIResource
OBJECT_NAME = 'login_link'
def self.retrieve(id, opts=nil)
raise NotImplementedError.new("Login links do not have IDs and cannot be retrieved. They can only be created using accounts.login_links.create")
end
end
end

View File

@ -44,6 +44,7 @@ module Stripe
Invoice::OBJECT_NAME => Invoice,
InvoiceItem::OBJECT_NAME => InvoiceItem,
InvoiceLineItem::OBJECT_NAME => InvoiceLineItem,
LoginLink::OBJECT_NAME => LoginLink,
Order::OBJECT_NAME => Order,
OrderReturn::OBJECT_NAME => OrderReturn,
Payout::OBJECT_NAME => Payout,

View File

@ -0,0 +1,27 @@
require File.expand_path('../../test_helper', __FILE__)
module Stripe
class LoginLinkTest < Test::Unit::TestCase
FIXTURE = API_FIXTURES.fetch(:login_link)
setup do
account_fixture = API_FIXTURES.fetch(:account)
@account = Stripe::Account.retrieve(account_fixture[:id])
end
should "not be retrievable" do
assert_raises NotImplementedError do
Stripe::LoginLink.retrieve('foo')
end
end
should "be creatable" do
stub_request(:post, "#{Stripe.api_base}/v1/accounts/#{@account.id}/login_links").
to_return(body: JSON.generate(FIXTURE))
login_link = @account.login_links.create
assert_requested :post,
"#{Stripe.api_base}/v1/accounts/#{@account.id}/login_links"
assert login_link.kind_of?(Stripe::LoginLink)
end
end
end