Sha256: 9531c7851dcf34d43e528bbf32c5bacb720c1a1380d991cc8c8dc0a315a7ce79

Contents?: true

Size: 1.5 KB

Versions: 9

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)
        true if response.success?
      end

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
paddle-2.7.0 lib/paddle/classic/resources/users.rb
paddle-2.6.0 lib/paddle/classic/resources/users.rb
paddle-2.5.2 lib/paddle/classic/resources/users.rb
paddle-2.5.1 lib/paddle/classic/resources/users.rb
paddle-2.5.0 lib/paddle/classic/resources/users.rb
paddle-2.4.1 lib/paddle/classic/resources/users.rb
paddle-2.4.0 lib/paddle/classic/resources/users.rb
paddle-2.3.0 lib/paddle/classic/resources/users.rb
paddle-2.2.1 lib/paddle/classic/resources/users.rb