ソースを参照

Merge pull request #519 from Shopify/tf/delivery-confirmation-details

Update DeliveryConfirmation and Conversation Ping resources for Feedback API
brownianmover 6 年 前
コミット
d4402bc3e4

+ 4 - 0
CHANGELOG

@@ -1,3 +1,7 @@
+== Version 5.2.3
+
+* Update delivery confirmation resource to delivery confirmation details resource.
+
 == Version 5.2.2
 
 * Add delivery confirmation endpoint to Ping resources.

+ 12 - 15
lib/shopify_api/resources/ping/conversation.rb

@@ -15,31 +15,28 @@ module ShopifyAPI
       end
 
       def successful_delivery(message_id:, delivery_timestamp:)
-        delivery_details = ShopifyAPI::Ping::DeliveryConfirmation.new(
-          conversation_id: id,
-          message_id: message_id,
-          delivery_confirmation_details: {
-            delivered: true,
-            confirmation_timestamp: delivery_timestamp,
-          }
+        delivery_details = ShopifyAPI::Ping::DeliveryConfirmationDetails.new(
+          delivery_attrs(message_id, delivery_timestamp).merge(delivered: true)
         )
         delivery_details.save
         delivery_details
       end
 
       def failed_delivery(message_id:, delivery_timestamp:, details:)
-        delivery_details = ShopifyAPI::Ping::DeliveryConfirmation.new(
-          conversation_id: id,
-          message_id: message_id,
-          delivery_confirmation_details: {
-            delivered: false,
-            confirmation_timestamp: delivery_timestamp,
-            details: details,
-          }
+        delivery_details = ShopifyAPI::Ping::DeliveryConfirmationDetails.new(
+          delivery_attrs(message_id, delivery_timestamp).merge(delivered: false, details: details)
         )
         delivery_details.save
         delivery_details
       end
+
+      def delivery_attrs(message_id, delivery_timestamp)
+        {
+          conversation_id: id,
+          message_id: message_id,
+          confirmation_timestamp: delivery_timestamp,
+        }
+      end
     end
   end
 end

+ 1 - 1
lib/shopify_api/resources/ping/delivery_confirmation.rb → lib/shopify_api/resources/ping/delivery_confirmation_details.rb

@@ -2,7 +2,7 @@
 
 module ShopifyAPI
   module Ping
-    class DeliveryConfirmation < Base
+    class DeliveryConfirmationDetails < Base
       self.prefix = "/admin/api/ping-api/v1/conversations/:conversation_id/messages/:message_id/"
       self.collection_name = "delivery_confirmation"
     end

+ 1 - 1
lib/shopify_api/version.rb

@@ -1,3 +1,3 @@
 module ShopifyAPI
-  VERSION = "5.2.2"
+  VERSION = "5.2.3"
 end