Class: Paddle::Classic::UsersResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/paddle/classic/resources/users.rb

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from Paddle::Classic::Resource

Instance Method Details

#cancel(subscription_id:) ⇒ Object



33
34
35
36
37
# File 'lib/paddle/classic/resources/users.rb', line 33

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

#list(**params) ⇒ Object



4
5
6
7
# File 'lib/paddle/classic/resources/users.rb', line 4

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

#pause(subscription_id:, **params) ⇒ Object



15
16
17
18
19
# File 'lib/paddle/classic/resources/users.rb', line 15

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

#unpause(subscription_id:, **params) ⇒ Object



21
22
23
24
25
# File 'lib/paddle/classic/resources/users.rb', line 21

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

#update(subscription_id:, **params) ⇒ Object



9
10
11
12
13
# File 'lib/paddle/classic/resources/users.rb', line 9

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

#update_postcode(subscription_id:, postcode:) ⇒ Object



27
28
29
30
31
# File 'lib/paddle/classic/resources/users.rb', line 27

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