Browse Source

Add support for ApiPermissions#destroy

Jamie Dwyer 6 years ago
parent
commit
50b5d93bdb

+ 9 - 0
lib/shopify_api/resources/api_permission.rb

@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+module ShopifyAPI
+  class ApiPermission < Base
+    def self.destroy
+      delete(:current)
+    end
+  end
+end

+ 8 - 0
lib/shopify_api/resources/o_auth.rb

@@ -1,8 +1,16 @@
+# frozen_string_literal: true
+
+# This resource is deprecated and will be removed in a future version of this gem.
+# Use ShopifyAPI::ApiPermission.destroy instead
+
 module ShopifyAPI
   class OAuth < Base
     self.collection_name = 'oauth'
 
     def self.revoke
+      warn '[DEPRECATED] ShopifyAPI::OAuth#revoke is deprecated and will be removed in a future version. ' \
+        'Use ShopifyAPI::ApiPermission#destroy instead.'
+
       delete(:revoke)
     end
   end

+ 9 - 0
test/api_permission_test.rb

@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+require 'test_helper'
+
+class ApiPermissionTest < Test::Unit::TestCase
+  test "revoke access token" do
+    fake "api_permissions/current", method: :delete, status: 200, body: "{}"
+    assert ShopifyAPI::ApiPermission.destroy
+  end
+end