Class: Apertur::Resources::Destinations

Inherits:
Object
  • Object
show all
Defined in:
lib/apertur/resources/destinations.rb

Overview

Manage delivery destinations within a project.

Destinations define where uploaded images are delivered (e.g. cloud storage buckets, webhooks, etc.).

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ Destinations

Returns a new instance of Destinations.

Parameters:



11
12
13
# File 'lib/apertur/resources/destinations.rb', line 11

def initialize(http)
  @http = http
end

Instance Method Details

#create(project_id, **config) ⇒ Hash

Create a new destination.

Parameters:

  • project_id (String)

    the project ID

  • config (Hash)

    destination configuration

Returns:

  • (Hash)

    the created destination



28
29
30
# File 'lib/apertur/resources/destinations.rb', line 28

def create(project_id, **config)
  @http.request(:post, "/api/v1/projects/#{project_id}/destinations", body: config)
end

#delete(project_id, dest_id) ⇒ nil

Delete a destination.

Parameters:

  • project_id (String)

    the project ID

  • dest_id (String)

    the destination ID

Returns:

  • (nil)


47
48
49
# File 'lib/apertur/resources/destinations.rb', line 47

def delete(project_id, dest_id)
  @http.request(:delete, "/api/v1/projects/#{project_id}/destinations/#{dest_id}")
end

#list(project_id) ⇒ Array<Hash>

List all destinations for a project.

Parameters:

  • project_id (String)

    the project ID

Returns:

  • (Array<Hash>)

    list of destinations



19
20
21
# File 'lib/apertur/resources/destinations.rb', line 19

def list(project_id)
  @http.request(:get, "/api/v1/projects/#{project_id}/destinations")
end

#test(project_id, dest_id) ⇒ Hash

Send a test payload to a destination.

Parameters:

  • project_id (String)

    the project ID

  • dest_id (String)

    the destination ID

Returns:

  • (Hash)

    test result



56
57
58
# File 'lib/apertur/resources/destinations.rb', line 56

def test(project_id, dest_id)
  @http.request(:post, "/api/v1/projects/#{project_id}/destinations/#{dest_id}/test")
end

#update(project_id, dest_id, **config) ⇒ Hash

Update an existing destination.

Parameters:

  • project_id (String)

    the project ID

  • dest_id (String)

    the destination ID

  • config (Hash)

    fields to update

Returns:

  • (Hash)

    the updated destination



38
39
40
# File 'lib/apertur/resources/destinations.rb', line 38

def update(project_id, dest_id, **config)
  @http.request(:patch, "/api/v1/projects/#{project_id}/destinations/#{dest_id}", body: config)
end