Class: BundleUp::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/bundleup/proxy.rb

Overview

Client for proxy API requests.

Constant Summary collapse

BASE_URL =
'https://proxy.bundleup.io'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, connection_id) ⇒ Proxy

Returns a new instance of Proxy.



10
11
12
13
# File 'lib/bundleup/proxy.rb', line 10

def initialize(api_key, connection_id)
  @api_key = api_key
  @connection_id = connection_id
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



8
9
10
# File 'lib/bundleup/proxy.rb', line 8

def api_key
  @api_key
end

#connection_idObject (readonly)

Returns the value of attribute connection_id.



8
9
10
# File 'lib/bundleup/proxy.rb', line 8

def connection_id
  @connection_id
end

Instance Method Details

#delete(path, headers: {}) ⇒ Object

Raises:

  • (ArgumentError)


47
48
49
50
51
52
53
# File 'lib/bundleup/proxy.rb', line 47

def delete(path, headers: {})
  raise ArgumentError, 'Path is required for DELETE request' unless path

  # Merge any additional headers
  request_headers = connection.headers.merge(headers)
  connection.delete(path, nil, request_headers)
end

#get(path, headers: {}) ⇒ Object

Raises:

  • (ArgumentError)


15
16
17
18
19
20
21
# File 'lib/bundleup/proxy.rb', line 15

def get(path, headers: {})
  raise ArgumentError, 'Path is required for GET request' unless path

  # Merge any additional headers
  request_headers = connection.headers.merge(headers)
  connection.get(path, nil, request_headers)
end

#patch(path, body: {}, headers: {}) ⇒ Object

Raises:

  • (ArgumentError)


39
40
41
42
43
44
45
# File 'lib/bundleup/proxy.rb', line 39

def patch(path, body: {}, headers: {})
  raise ArgumentError, 'Path is required for PATCH request' unless path

  # Merge any additional headers
  request_headers = connection.headers.merge(headers)
  connection.patch(path, body.to_json, request_headers)
end

#post(path, body: {}, headers: {}) ⇒ Object

Raises:

  • (ArgumentError)


23
24
25
26
27
28
29
# File 'lib/bundleup/proxy.rb', line 23

def post(path, body: {}, headers: {})
  raise ArgumentError, 'Path is required for POST request' unless path

  # Merge any additional headers
  request_headers = connection.headers.merge(headers)
  connection.post(path, body.to_json, request_headers)
end

#put(path, body: {}, headers: {}) ⇒ Object

Raises:

  • (ArgumentError)


31
32
33
34
35
36
37
# File 'lib/bundleup/proxy.rb', line 31

def put(path, body: {}, headers: {})
  raise ArgumentError, 'Path is required for PUT request' unless path

  # Merge any additional headers
  request_headers = connection.headers.merge(headers)
  connection.put(path, body.to_json, request_headers)
end