Class: Polar::Resources::Subscriptions

Inherits:
Base
  • Object
show all
Defined in:
lib/polar/resources/subscriptions.rb

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Polar::Resources::Base

Instance Method Details

#export(params = {}) ⇒ Hash

Export subscriptions

Parameters:

  • params (Hash) (defaults to: {})

    Export parameters

Returns:

  • (Hash)

    Export job details



24
25
26
27
# File 'lib/polar/resources/subscriptions.rb', line 24

def export(params = {})
  response = post('/subscriptions/export', params)
  response.body
end

#get(id) ⇒ Hash

Get a subscription by ID

Parameters:

  • id (String)

    Subscription ID

Returns:

  • (Hash)

    Subscription data



32
33
34
35
# File 'lib/polar/resources/subscriptions.rb', line 32

def get(id)
  response = get("/subscriptions/#{id}")
  response.body
end

#list(params = {}) ⇒ PaginatedResponse

List subscriptions

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters

Options Hash (params):

  • :organization_id (String)

    Filter by organization ID

  • :customer_id (String)

    Filter by customer ID

  • :product_id (String)

    Filter by product ID

  • :status (String)

    Filter by status

  • :page (Integer)

    Page number

  • :limit (Integer)

    Items per page

Returns:



17
18
19
# File 'lib/polar/resources/subscriptions.rb', line 17

def list(params = {})
  paginate('/subscriptions/', params)
end

#revoke(id) ⇒ Hash

Revoke (cancel) a subscription

Parameters:

  • id (String)

    Subscription ID

Returns:

  • (Hash)

    Revoked subscription



49
50
51
52
# File 'lib/polar/resources/subscriptions.rb', line 49

def revoke(id)
  response = post("/subscriptions/#{id}/revoke")
  response.body
end

#update(id, attributes) ⇒ Hash

Update a subscription

Parameters:

  • id (String)

    Subscription ID

  • attributes (Hash)

    Updated attributes

Returns:

  • (Hash)

    Updated subscription



41
42
43
44
# File 'lib/polar/resources/subscriptions.rb', line 41

def update(id, attributes)
  response = patch("/subscriptions/#{id}", attributes)
  response.body
end