Class: Streaker::API

Inherits:
Object
  • Object
show all
Defined in:
lib/streaker/api.rb

Overview

Allow the streaker gem to execute http calls to the streak api

Instance Method Summary collapse

Constructor Details

#initialize(api_key: nil) ⇒ API

Returns a new instance of API.



6
7
8
# File 'lib/streaker/api.rb', line 6

def initialize(api_key: nil)
  @api_key = api_key || Streaker.configuration.api_key
end

Instance Method Details

#create_box(pipeline_key, name:, assigned_to: []) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/streaker/api.rb', line 19

def create_box(pipeline_key, name:, assigned_to: [])
  response = client.put(
    "#{STREAK_URL}/api/v1/pipelines/#{pipeline_key}/boxes",
    form: create_box_params(name: name, assigned_to: assigned_to)
  )

  JSON.parse(response.body.to_s)
end

#find_box(box_key) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/streaker/api.rb', line 28

def find_box(box_key)
  response = client.get(
    "#{STREAK_URL}/api/v1/boxes/#{box_key}"
  )

  JSON.parse(response.body.to_s)
end

#update_box(key, attributes) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/streaker/api.rb', line 10

def update_box(key, attributes)
  response = client.post(
    "#{STREAK_URL}/api/v1/boxes/#{key}",
    json: update_box_params(attributes)
  )

  JSON.parse(response.body.to_s)
end