Class: PagiiiApi::Photo

Inherits:
Object
  • Object
show all
Defined in:
lib/pagiii_api/photo.rb

Class Method Summary collapse

Class Method Details

.attach(photo_id:, path:) ⇒ Object



20
21
22
23
24
25
# File 'lib/pagiii_api/photo.rb', line 20

def attach(photo_id:, path:)
  conn = Pagiii.create_upload_connection
  payload = { image: Faraday::FilePart.new(path, 'image/jpeg') }
  response = conn.post("/api/v1/admin/photos/#{photo_id}/attach", payload)
  Pagiii.build_response(response)
end

.create(options) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/pagiii_api/photo.rb', line 4

def create(options)
  conn = Pagiii.create_connection

  response = conn.post("/api/v1/admin/photos") do |req|
    req.body = {
      photo: options
    }.to_json
  end
  Pagiii.build_response(response)
end

.delete(photo_id:) ⇒ Object



15
16
17
18
# File 'lib/pagiii_api/photo.rb', line 15

def delete(photo_id:)
  conn = Pagiii.create_connection
  conn.post("/api/v1/admin/photos/#{photo_id}")
end