shopify_api 6.0.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +10 -19
- data/CHANGELOG +11 -0
- data/Gemfile +1 -2
- data/Gemfile_ar41 +5 -0
- data/Gemfile_ar50 +5 -0
- data/Gemfile_ar51 +5 -0
- data/Gemfile_ar_master +0 -1
- data/README.md +116 -9
- data/RELEASING +2 -5
- data/lib/shopify_api.rb +4 -4
- data/lib/shopify_api/api_version.rb +116 -0
- data/lib/shopify_api/disable_prefix_check.rb +31 -0
- data/lib/shopify_api/limits.rb +5 -5
- data/lib/shopify_api/resources/access_scope.rb +6 -1
- data/lib/shopify_api/resources/asset.rb +15 -11
- data/lib/shopify_api/resources/base.rb +63 -1
- data/lib/shopify_api/resources/fulfillment_event.rb +1 -1
- data/lib/shopify_api/resources/graphql.rb +1 -1
- data/lib/shopify_api/resources/inventory_level.rb +2 -2
- data/lib/shopify_api/resources/location.rb +1 -1
- data/lib/shopify_api/resources/marketing_event.rb +2 -0
- data/lib/shopify_api/resources/payment.rb +1 -1
- data/lib/shopify_api/resources/refund.rb +4 -3
- data/lib/shopify_api/resources/shipping_rate.rb +1 -1
- data/lib/shopify_api/resources/shop.rb +4 -2
- data/lib/shopify_api/resources/smart_collection.rb +1 -1
- data/lib/shopify_api/session.rb +45 -16
- data/lib/shopify_api/version.rb +1 -1
- data/shopify_api.gemspec +3 -2
- data/test/access_scope_test.rb +23 -0
- data/test/api_version_test.rb +144 -0
- data/test/base_test.rb +75 -32
- data/test/detailed_log_subscriber_test.rb +51 -12
- data/test/fixtures/access_scopes.json +10 -0
- data/test/limits_test.rb +2 -2
- data/test/marketing_event_test.rb +1 -1
- data/test/recurring_application_charge_test.rb +3 -9
- data/test/session_test.rb +158 -32
- data/test/test_helper.rb +27 -11
- metadata +33 -21
- data/Gemfile_ar30 +0 -6
- data/Gemfile_ar31 +0 -6
- data/Gemfile_ar32 +0 -6
- data/Gemfile_ar40 +0 -6
- data/lib/active_resource/base_ext.rb +0 -21
- data/lib/active_resource/disable_prefix_check.rb +0 -36
- data/lib/active_resource/to_query.rb +0 -10
- data/lib/shopify_api/json_format.rb +0 -18
- data/lib/shopify_api/resources/o_auth.rb +0 -17
- data/lib/shopify_api/resources/ping/conversation.rb +0 -42
- data/lib/shopify_api/resources/ping/delivery_confirmation_details.rb +0 -10
- data/lib/shopify_api/resources/ping/message.rb +0 -8
- data/test/fixtures/o_auth_revoke.json +0 -5
- data/test/o_auth_test.rb +0 -8
- data/test/ping/conversation_test.rb +0 -71
- data/test/ping/message_test.rb +0 -23
data/Gemfile_ar30
DELETED
data/Gemfile_ar31
DELETED
data/Gemfile_ar32
DELETED
data/Gemfile_ar40
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module ActiveResource
|
2
|
-
class Base
|
3
|
-
if ActiveResource::VERSION::MAJOR < 4
|
4
|
-
# Backported from ActiveResource master branch
|
5
|
-
def self.headers
|
6
|
-
@headers ||= {}
|
7
|
-
|
8
|
-
if superclass != Object && superclass.headers
|
9
|
-
@headers = superclass.headers.merge(@headers)
|
10
|
-
else
|
11
|
-
@headers
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
# https://github.com/rails/activeresource/commit/dfef85ce8f653f75673631b2950fcdb0781c313c
|
16
|
-
def self.delete(id, options = {})
|
17
|
-
connection.delete(element_path(id, options), headers)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module DisablePrefixCheck
|
2
|
-
extend ActiveSupport::Concern
|
3
|
-
|
4
|
-
module ClassMethods
|
5
|
-
def check_prefix_options(options)
|
6
|
-
end
|
7
|
-
|
8
|
-
# `flexible = true` is hack to allow multiple things through the same AR class
|
9
|
-
def conditional_prefix(resource, flexible = false)
|
10
|
-
resource_id = "#{resource}_id".to_sym
|
11
|
-
resource_type = flexible ? ":#{resource}" : resource.to_s.pluralize
|
12
|
-
|
13
|
-
init_prefix_explicit resource_type, resource_id
|
14
|
-
|
15
|
-
define_singleton_method :prefix do |options = {}|
|
16
|
-
resource_type = options[resource] if flexible
|
17
|
-
|
18
|
-
options[resource_id].nil? ? "/admin/" : "/admin/#{resource_type}/#{options[resource_id]}/"
|
19
|
-
end
|
20
|
-
|
21
|
-
define_singleton_method :instantiate_record do |record, prefix_options = {}|
|
22
|
-
new_record(record).tap do |resource|
|
23
|
-
resource.prefix_options = prefix_options unless prefix_options.blank?
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def new_record(record)
|
29
|
-
if ActiveSupport::VERSION::MAJOR == 3 && ActiveSupport::VERSION::MINOR == 0
|
30
|
-
new(record)
|
31
|
-
else
|
32
|
-
new(record, true)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# ActiveSupport 3.0 doesn't URL-encode paths with arrays as params properly.
|
2
|
-
# Backported from ActiveSupport > 3.0
|
3
|
-
if ActiveSupport::VERSION::MAJOR == 3 && ActiveSupport::VERSION::MINOR == 0
|
4
|
-
class Object
|
5
|
-
def to_query(key)
|
6
|
-
require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
|
7
|
-
"#{CGI.escape(key.to_param)}=#{CGI.escape(to_param.to_s)}"
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module ActiveResource
|
2
|
-
|
3
|
-
# ActiveResource 3.1 removes root on decoding, so this patch is only needed in 3.0
|
4
|
-
if ActiveResource::VERSION::MAJOR == 3 && ActiveResource::VERSION::MINOR == 0
|
5
|
-
module Formats
|
6
|
-
module JsonFormat
|
7
|
-
def decode(json)
|
8
|
-
data = ActiveSupport::JSON.decode(json)
|
9
|
-
if data.is_a?(Hash) && data.keys.size == 1
|
10
|
-
data.values.first
|
11
|
-
else
|
12
|
-
data
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# This resource is deprecated and will be removed in a future version of this gem.
|
4
|
-
# Use ShopifyAPI::ApiPermission.destroy instead
|
5
|
-
|
6
|
-
module ShopifyAPI
|
7
|
-
class OAuth < Base
|
8
|
-
self.collection_name = 'oauth'
|
9
|
-
|
10
|
-
def self.revoke
|
11
|
-
warn '[DEPRECATED] ShopifyAPI::OAuth#revoke is deprecated and will be removed in a future version. ' \
|
12
|
-
'Use ShopifyAPI::ApiPermission#destroy instead.'
|
13
|
-
|
14
|
-
delete(:revoke)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ShopifyAPI
|
4
|
-
module Ping
|
5
|
-
class Conversation < Base
|
6
|
-
self.prefix = "/admin/api/ping-api/v1/"
|
7
|
-
|
8
|
-
def send_message(message_attrs)
|
9
|
-
message = ShopifyAPI::Ping::Message.new(
|
10
|
-
message_attrs.merge(conversation_id: id)
|
11
|
-
)
|
12
|
-
|
13
|
-
message.save
|
14
|
-
message
|
15
|
-
end
|
16
|
-
|
17
|
-
def successful_delivery(message_id:, delivery_timestamp:)
|
18
|
-
delivery_details = ShopifyAPI::Ping::DeliveryConfirmationDetails.new(
|
19
|
-
delivery_attrs(message_id, delivery_timestamp).merge(delivered: true)
|
20
|
-
)
|
21
|
-
delivery_details.save
|
22
|
-
delivery_details
|
23
|
-
end
|
24
|
-
|
25
|
-
def failed_delivery(message_id:, delivery_timestamp:, details:)
|
26
|
-
delivery_details = ShopifyAPI::Ping::DeliveryConfirmationDetails.new(
|
27
|
-
delivery_attrs(message_id, delivery_timestamp).merge(delivered: false, details: details)
|
28
|
-
)
|
29
|
-
delivery_details.save
|
30
|
-
delivery_details
|
31
|
-
end
|
32
|
-
|
33
|
-
def delivery_attrs(message_id, delivery_timestamp)
|
34
|
-
{
|
35
|
-
conversation_id: id,
|
36
|
-
message_id: message_id,
|
37
|
-
confirmation_timestamp: delivery_timestamp,
|
38
|
-
}
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ShopifyAPI
|
4
|
-
module Ping
|
5
|
-
class DeliveryConfirmationDetails < Base
|
6
|
-
self.prefix = "/admin/api/ping-api/v1/conversations/:conversation_id/messages/:message_id/"
|
7
|
-
self.collection_name = "delivery_confirmation"
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
data/test/o_auth_test.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class PingConversationTest < Test::Unit::TestCase
|
6
|
-
def test_create_conversation
|
7
|
-
fake "api/ping-api/v1/conversations", method: :post, body: load_fixture('ping/conversation')
|
8
|
-
|
9
|
-
conversation = ShopifyAPI::Ping::Conversation.new(
|
10
|
-
topic: 'my topic',
|
11
|
-
participants: [
|
12
|
-
{
|
13
|
-
name: 'foo',
|
14
|
-
id: 'test',
|
15
|
-
group: 'customer',
|
16
|
-
},
|
17
|
-
]
|
18
|
-
)
|
19
|
-
|
20
|
-
conversation.save
|
21
|
-
|
22
|
-
assert_equal "d315d4f7-53bd-49ec-8808-23f6db3c641a", conversation.id
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_send_message
|
26
|
-
fake "api/ping-api/v1/conversations/123/messages", method: :post, body: load_fixture('ping/message')
|
27
|
-
|
28
|
-
conversation = ShopifyAPI::Ping::Conversation.new(id: '123')
|
29
|
-
message = conversation.send_message(
|
30
|
-
dedupe_key: SecureRandom.uuid,
|
31
|
-
content: {
|
32
|
-
text: "Hello from shopify_api",
|
33
|
-
},
|
34
|
-
sender_id: 'test',
|
35
|
-
)
|
36
|
-
|
37
|
-
assert_equal "d0c7a2e6-8084-4e79-8483-e4a1352b81f7", message.id
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_successful_delivery
|
41
|
-
fake("api/ping-api/v1/conversations/123/messages/111/delivery_confirmation",
|
42
|
-
method: :post,
|
43
|
-
body: load_fixture('ping/successful_delivery_confirmation'))
|
44
|
-
|
45
|
-
conversation = ShopifyAPI::Ping::Conversation.new(id: '123')
|
46
|
-
delivery_confirmation = conversation.successful_delivery(
|
47
|
-
message_id: '111',
|
48
|
-
delivery_timestamp: "2018-08-29T22:16:05.589479Z"
|
49
|
-
)
|
50
|
-
|
51
|
-
assert_equal("true", delivery_confirmation.delivered)
|
52
|
-
assert_equal("2018-08-29T22:16:05.589479Z", delivery_confirmation.delivery_timestamp)
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_failed_delivery
|
56
|
-
fake("api/ping-api/v1/conversations/123/messages/111/delivery_confirmation",
|
57
|
-
method: :post,
|
58
|
-
body: load_fixture('ping/failed_delivery_confirmation'))
|
59
|
-
|
60
|
-
conversation = ShopifyAPI::Ping::Conversation.new(id: '123')
|
61
|
-
delivery_confirmation = conversation.failed_delivery(
|
62
|
-
message_id: '111',
|
63
|
-
delivery_timestamp: Time.now.to_s,
|
64
|
-
details: "Integration failed to deliver message."
|
65
|
-
)
|
66
|
-
|
67
|
-
assert_equal("false", delivery_confirmation.delivered)
|
68
|
-
assert_equal("2018-08-29T22:16:05.589479Z", delivery_confirmation.delivery_timestamp)
|
69
|
-
assert_equal("Integration failed to deliver message.", delivery_confirmation.details)
|
70
|
-
end
|
71
|
-
end
|
data/test/ping/message_test.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class PingMessageTest < Test::Unit::TestCase
|
6
|
-
def test_create_message
|
7
|
-
fake("api/ping-api/v1/conversations/123/messages",
|
8
|
-
method: :post,
|
9
|
-
body: load_fixture('ping/message'))
|
10
|
-
|
11
|
-
message = ShopifyAPI::Ping::Message.new(
|
12
|
-
dedupe_key: SecureRandom.uuid,
|
13
|
-
content: {
|
14
|
-
text: "Hello from shopify_api",
|
15
|
-
},
|
16
|
-
sender_id: 'test',
|
17
|
-
conversation_id: '123',
|
18
|
-
)
|
19
|
-
|
20
|
-
message.save
|
21
|
-
assert_equal("d0c7a2e6-8084-4e79-8483-e4a1352b81f7", message.id)
|
22
|
-
end
|
23
|
-
end
|