shopify_api 4.12.0 → 4.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shopify_api/resources/ping.rb +3 -0
- data/lib/shopify_api/resources/ping/conversation.rb +18 -0
- data/lib/shopify_api/resources/ping/message.rb +9 -0
- data/lib/shopify_api/version.rb +1 -1
- data/test/fixtures/ping/conversation.json +1 -0
- data/test/fixtures/ping/message.json +1 -0
- data/test/ping/conversation_test.rb +39 -0
- data/test/test_helper.rb +7 -5
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef057d0e70073f7c63a076b7f878c1c3afd062d0
|
4
|
+
data.tar.gz: 477cf304d0a68dc7e68cfac7e39c9af5617611c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c24fa3742f763e0f798a4e2d0eccd37ff2db06ba21e08e09d5853584550398db112354f39b9fd6edc55af2cc8e438f5d04b8e3ade7e704c81e2eda2a8236338f
|
7
|
+
data.tar.gz: 9886ecfff88b5b9e7dac1e1e1948fbe3ea3a0c69cbc9f13f601c413dead928bdfc68678f81d06ad74f277631f8048628252f390a37717bf17d9c1b6c4c3e016b
|
@@ -0,0 +1,18 @@
|
|
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
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/shopify_api/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
{"conversation":{"id":"d315d4f7-53bd-49ec-8808-23f6db3c641a","name":"my topic","participants":{"counts":{"total":1},"data":[{"id":"test","name":"foo","avatar":null,"group":"customer"}]},"shopify_account":{"domain":"backpackinghacks.myshopify.com"}}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"message":{"id":"d0c7a2e6-8084-4e79-8483-e4a1352b81f7","sender_id":"test","sender":{"id":"test","name":"foo","avatar":null,"group":"customer"},"content":{"text":"Hello from shopify_api"},"sent_at":"2018-08-29T22:16:05.589479Z"}}
|
@@ -0,0 +1,39 @@
|
|
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
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -30,11 +30,13 @@ class Test::Unit::TestCase < Minitest::Unit::TestCase
|
|
30
30
|
|
31
31
|
def setup
|
32
32
|
ActiveResource::Base.format = :json
|
33
|
-
ShopifyAPI.
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
[ShopifyAPI, ShopifyAPI::Ping].each do |mod|
|
34
|
+
mod.constants.each do |const|
|
35
|
+
begin
|
36
|
+
const = mod.const_get(const)
|
37
|
+
const.format = :json if const.respond_to?(:format=)
|
38
|
+
rescue NameError
|
39
|
+
end
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopify_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeresource
|
@@ -214,6 +214,9 @@ files:
|
|
214
214
|
- lib/shopify_api/resources/order_risk.rb
|
215
215
|
- lib/shopify_api/resources/page.rb
|
216
216
|
- lib/shopify_api/resources/payment_details.rb
|
217
|
+
- lib/shopify_api/resources/ping.rb
|
218
|
+
- lib/shopify_api/resources/ping/conversation.rb
|
219
|
+
- lib/shopify_api/resources/ping/message.rb
|
217
220
|
- lib/shopify_api/resources/policy.rb
|
218
221
|
- lib/shopify_api/resources/price_rule.rb
|
219
222
|
- lib/shopify_api/resources/product.rb
|
@@ -320,6 +323,8 @@ files:
|
|
320
323
|
- test/fixtures/order_risks.json
|
321
324
|
- test/fixtures/order_with_properties.json
|
322
325
|
- test/fixtures/orders.json
|
326
|
+
- test/fixtures/ping/conversation.json
|
327
|
+
- test/fixtures/ping/message.json
|
323
328
|
- test/fixtures/policies.json
|
324
329
|
- test/fixtures/price_rule.json
|
325
330
|
- test/fixtures/price_rules.json
|
@@ -366,6 +371,7 @@ files:
|
|
366
371
|
- test/o_auth_test.rb
|
367
372
|
- test/order_risk_test.rb
|
368
373
|
- test/order_test.rb
|
374
|
+
- test/ping/conversation_test.rb
|
369
375
|
- test/policy_test.rb
|
370
376
|
- test/price_rule_test.rb
|
371
377
|
- test/product_listing_test.rb
|