drip-ruby 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,23 +0,0 @@
1
- module Drip
2
- class Client
3
- module Purchases
4
- # Public: Create a purchase.
5
- #
6
- # email - Required. The String email address of the subscriber.
7
- # amount - Required. The total amount of the purchase in cents.
8
- # options - Required. A Hash of additional order options. Refer to the
9
- # Drip API docs for the required schema.
10
- # Returns a Drip::Response.
11
- # See https://developer.drip.com/#orders
12
- #
13
- # DEPRECATED: The beta Purchase endpoint has been deprecated and this method now sends
14
- # requests to the Order creation endpoint. Please use `create_or_update_order` instead
15
- def create_purchase(email, amount, options = {})
16
- warn "[DEPRECATED] `create_purchase` is deprecated. Please use `create_or_update_order` instead."
17
-
18
- data = options.merge({ amount: amount, email: email })
19
- post "#{account_id}/orders", generate_resource("orders", data)
20
- end
21
- end
22
- end
23
- end
@@ -1,47 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../test_helper.rb'
2
-
3
- class Drip::Client::PurchasesTest < Drip::TestCase
4
- def setup
5
- @stubs = Faraday::Adapter::Test::Stubs.new
6
-
7
- @connection = Faraday.new do |builder|
8
- builder.adapter :test, @stubs
9
- end
10
-
11
- @client = Drip::Client.new { |c| c.account_id = "12345" }
12
- @client.expects(:connection).at_least_once.returns(@connection)
13
- end
14
-
15
- context "#create_purchase" do
16
- setup do
17
- @email = "derrick@getdrip.com"
18
- @amount = 4900
19
- @options = {
20
- "email": @email,
21
- "provider": "shopify",
22
- "upstream_id": "abcdef",
23
- "amount": @amount,
24
- "tax": 100,
25
- "fees": 0,
26
- "discount": 0,
27
- "currency_code": "USD",
28
- "properties": {
29
- "size": "medium",
30
- "color": "red"
31
- }
32
- }
33
- @payload = { "orders" => [@options] }.to_json
34
- @response_status = 202
35
- @response_body = stub
36
-
37
- @stubs.post "12345/orders", @payload do
38
- [@response_status, {}, @response_body]
39
- end
40
- end
41
-
42
- should "send the right request" do
43
- expected = Drip::Response.new(@response_status, @response_body)
44
- assert_equal expected, @client.create_purchase(@email, @amount, @options)
45
- end
46
- end
47
- end