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.
- checksums.yaml +5 -5
- data/.rubocop.yml +14 -1
- data/.rubocop_todo.yml +51 -85
- data/.travis.yml +1 -0
- data/CHANGELOG.md +62 -0
- data/Rakefile +4 -2
- data/drip-ruby.gemspec +6 -6
- data/lib/drip/client.rb +45 -34
- data/lib/drip/client/orders.rb +4 -4
- data/lib/drip/errors.rb +3 -0
- data/lib/drip/response.rb +5 -5
- data/lib/drip/version.rb +1 -1
- data/test/drip/client/accounts_test.rb +6 -15
- data/test/drip/client/broadcasts_test.rb +6 -15
- data/test/drip/client/campaign_subscriptions_test.rb +3 -11
- data/test/drip/client/campaigns_test.rb +15 -27
- data/test/drip/client/conversions_test.rb +6 -15
- data/test/drip/client/custom_fields_test.rb +3 -11
- data/test/drip/client/events_test.rb +12 -23
- data/test/drip/client/forms_test.rb +6 -15
- data/test/drip/client/orders_test.rb +48 -58
- data/test/drip/client/subscribers_test.rb +33 -51
- data/test/drip/client/tags_test.rb +9 -19
- data/test/drip/client/webhooks_test.rb +12 -23
- data/test/drip/client/workflow_triggers_test.rb +9 -19
- data/test/drip/client/workflows_test.rb +18 -31
- data/test/drip/client_test.rb +70 -3
- data/test/test_helper.rb +1 -8
- metadata +26 -27
- data/lib/drip/client/purchases.rb +0 -23
- data/test/drip/client/purchases_test.rb +0 -47
@@ -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
|