Adding support for listing file uploads.

This commit is contained in:
wangjohn 2015-01-12 11:59:50 -08:00
parent b080e9a7d1
commit ad26262a2c
4 changed files with 26 additions and 2 deletions

View File

@ -18,6 +18,13 @@ module Stripe
Util.convert_to_stripe_object(response, api_key)
end
def self.all(filters={}, opts={})
api_key, headers = Util.parse_opts(opts)
response, api_key = Stripe.request(
:get, self.url, api_key, filters, headers, UPLOADS_API_BASE)
Util.convert_to_stripe_object(response, api_key)
end
def refresh
response, api_key = Stripe.request(
:get, url, @api_key, @retrieve_options, self.class.request_headers, UPLOADS_API_BASE)

View File

@ -35,7 +35,8 @@ module Stripe
'plan' => Plan,
'recipient' => Recipient,
'refund' => Refund,
'subscription' => Subscription,
'subscription' => Subscription,
'file_upload' => FileUpload,
'transfer' => Transfer
}
end

View File

@ -17,5 +17,12 @@ module Stripe
c.refresh
assert_equal 1403047735, c.created
end
should "files should be listable" do
@mock.expects(:get).once.returns(test_response(test_file_array))
c = Stripe::FileUpload.all.data
assert c.kind_of? Array
assert c[0].kind_of? Stripe::FileUpload
end
end
end

View File

@ -185,12 +185,21 @@ module Stripe
def test_file(params={})
{
:object => "file_upload",
:id => "fil_test_file",
:created => 1403047735,
:size => 4908,
:purpose => params[:purpose] || "dispute_evidence",
:url => nil,
:mimetype => nil,
:type => nil,
}
end
def test_file_array
{
:data => [test_file, test_file, test_file],
:object => 'list',
:url => '/v1/files'
}
end