Skip to content

Commit

Permalink
file_link support
Browse files Browse the repository at this point in the history
  • Loading branch information
ob-stripe committed Aug 2, 2018
1 parent 704231a commit a190712
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ sudo: false
env:
global:
# If changing this number, please also change it in `test/test_helper.rb`.
- STRIPE_MOCK_VERSION=0.24.1
- STRIPE_MOCK_VERSION=0.25.0

cache:
directories:
Expand Down
1 change: 1 addition & 0 deletions lib/stripe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
require "stripe/ephemeral_key"
require "stripe/event"
require "stripe/exchange_rate"
require "stripe/file_link"
require "stripe/file_upload"
require "stripe/invoice"
require "stripe/invoice_item"
Expand Down
11 changes: 11 additions & 0 deletions lib/stripe/file_link.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

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

OBJECT_NAME = "file_link".freeze
end
end
1 change: 1 addition & 0 deletions lib/stripe/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def self.object_classes # rubocop:disable Metrics/MethodLength
EphemeralKey::OBJECT_NAME => EphemeralKey,
Event::OBJECT_NAME => Event,
ExchangeRate::OBJECT_NAME => ExchangeRate,
FileLink::OBJECT_NAME => FileLink,
FileUpload::OBJECT_NAME => FileUpload,
Invoice::OBJECT_NAME => Invoice,
InvoiceItem::OBJECT_NAME => InvoiceItem,
Expand Down
41 changes: 41 additions & 0 deletions test/stripe/file_link_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# frozen_string_literal: true

require File.expand_path("../../test_helper", __FILE__)

module Stripe
class FileLinkTest < Test::Unit::TestCase
should "be listable" do
file_links = Stripe::FileLink.list
assert_requested :get, "#{Stripe.api_base}/v1/file_links"
assert file_links.data.is_a?(Array)
assert file_links.first.is_a?(Stripe::FileLink)
end

should "be retrievable" do
file_link = Stripe::FileLink.retrieve("link_123")
assert_requested :get, "#{Stripe.api_base}/v1/file_links/link_123"
assert file_link.is_a?(Stripe::FileLink)
end

should "be creatable" do
file_link = Stripe::FileLink.create(
file: "file_123",
)
assert_requested :post, "#{Stripe.api_base}/v1/file_links"
assert file_link.is_a?(Stripe::FileLink)
end

should "be saveable" do
file_link = Stripe::FileLink.retrieve("link_123")
file_link.metadata["key"] = "value"
file_link.save
assert_requested :post, "#{Stripe.api_base}/v1/file_links/#{file_link.id}"
end

should "be updateable" do
file_link = Stripe::FileLink.update("link_123", metadata: { key: "value" })
assert_requested :post, "#{Stripe.api_base}/v1/file_links/link_123"
assert file_link.is_a?(Stripe::FileLink)
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 @@ -16,7 +16,7 @@
require File.expand_path("../test_data", __FILE__)

# If changing this number, please also change it in `.travis.yml`.
MOCK_MINIMUM_VERSION = "0.24.1".freeze
MOCK_MINIMUM_VERSION = "0.25.0".freeze
MOCK_PORT = ENV["STRIPE_MOCK_PORT"] || 12_111

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

0 comments on commit a190712

Please sign in to comment.