Class: Billingrails::Resources::Benefits

Inherits:
Object
  • Object
show all
Defined in:
lib/billingrails/resources/benefits.rb

Overview

Benefits resource

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Benefits

Returns a new instance of Benefits.

Parameters:

  • client (Client)

    The API client



10
11
12
# File 'lib/billingrails/resources/benefits.rb', line 10

def initialize(client)
  @client = client
end

Instance Method Details

#archive(id) ⇒ Hash

Archive a benefit

Archives a benefit.

Parameters:

  • id (String)

    Resource ID

Returns:

  • (Hash)

    Response data



77
78
79
80
# File 'lib/billingrails/resources/benefits.rb', line 77

def archive(id)
  path = "/benefits/#{id}/archive"
  @client.request(:post, path)
end

#create(data) ⇒ Hash

Create a benefit

Creates a benefit.

Parameters:

  • data (Hash)

    Request body

Returns:

  • (Hash)

    Response data



31
32
33
34
# File 'lib/billingrails/resources/benefits.rb', line 31

def create(data)
  path = "/benefits"
  @client.request(:post, path, body: data)
end

#delete(id) ⇒ Hash

Delete a benefit

Deletes a benefit by ID. Allowed only when the benefit is not assigned to any product, price or entitlements.

Parameters:

  • id (String)

    Resource ID

Returns:

  • (Hash)

    Response data



66
67
68
69
# File 'lib/billingrails/resources/benefits.rb', line 66

def delete(id)
  path = "/benefits/#{id}"
  @client.request(:delete, path)
end

#list(params: nil) ⇒ Hash

List benefits

Retrieves a list of benefits.

Parameters:

  • params (Hash, nil) (defaults to: nil)

    Query parameters

Returns:

  • (Hash)

    Response data



20
21
22
23
# File 'lib/billingrails/resources/benefits.rb', line 20

def list(params: nil)
  path = "/benefits"
  @client.request(:get, path, params: params)
end

#retrieve(id, params: nil) ⇒ Hash

Retrieve a benefit

Retrieves a benefit by ID.

Parameters:

  • id (String)

    Resource ID

  • params (Hash, nil) (defaults to: nil)

    Query parameters

Returns:

  • (Hash)

    Response data



43
44
45
46
# File 'lib/billingrails/resources/benefits.rb', line 43

def retrieve(id, params: nil)
  path = "/benefits/#{id}"
  @client.request(:get, path, params: params)
end

#unarchive(id) ⇒ Hash

Unarchive a benefit

Unarchives a benefit.

Parameters:

  • id (String)

    Resource ID

Returns:

  • (Hash)

    Response data



88
89
90
91
# File 'lib/billingrails/resources/benefits.rb', line 88

def unarchive(id)
  path = "/benefits/#{id}/unarchive"
  @client.request(:post, path)
end

#update(id, data) ⇒ Hash

Update a benefit

Updates a benefit.

Parameters:

  • id (String)

    Resource ID

  • data (Hash)

    Request body

Returns:

  • (Hash)

    Response data



55
56
57
58
# File 'lib/billingrails/resources/benefits.rb', line 55

def update(id, data)
  path = "/benefits/#{id}"
  @client.request(:patch, path, body: data)
end