Sha256: d09e7f02bf9961d55cbc9dda02771a17a840c50dd7907e13275e2fa82dd0a09a

Contents?: true

Size: 1.5 KB

Versions: 10

Compression:

Stored size: 1.5 KB

Contents

module Paddle
  module Classic
    class UsersResource < Resource

      def list(**params)
        response = post_request("2.0/subscription/users", body: params)
        Collection.from_response(response, type: User)
      end

      def update(subscription_id:, **params)
        attrs = {subscription_id: subscription_id}
        response = post_request("2.0/subscription/users/update", body: attrs.merge(params))
        User.new(response.body["response"]) if response.success?
      end

      def pause(subscription_id:, **params)
        attrs = {subscription_id: subscription_id, pause: true}
        response = post_request("2.0/subscription/users/update", body: attrs.merge(params))
        User.new(response.body["response"]) if response.success?
      end

      def unpause(subscription_id:, **params)
        attrs = {subscription_id: subscription_id, pause: false}
        response = post_request("2.0/subscription/users/update", body: attrs.merge(params))
        User.new(response.body["response"]) if response.success?
      end

      def update_postcode(subscription_id:, postcode:)
        attrs = {subscription_id: subscription_id, postcode: postcode}
        response = post_request("2.0/subscription/users/postcode", body: attrs)
        return true if response.success?
      end

      def cancel(subscription_id:)
        attrs = {subscription_id: subscription_id}
        response = post_request("2.0/subscription/users_cancel", body: attrs)
        return true if response.success?
      end

    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
paddle-2.2.0 lib/paddle/classic/resources/users.rb
paddle-2.1.4 lib/paddle/classic/resources/users.rb
paddle-2.1.3 lib/paddle/classic/resources/users.rb
paddle-2.1.2 lib/paddle/classic/resources/users.rb
paddle-2.1.1 lib/paddle/classic/resources/users.rb
paddle-2.1.0 lib/paddle/classic/resources/users.rb
paddle-2.0.0 lib/paddle/classic/resources/users.rb
paddle-1.1.2 lib/paddle/classic/resources/users.rb
paddle-1.1.1 lib/paddle/classic/resources/users.rb
paddle-1.1.0 lib/paddle/classic/resources/users.rb