Class: Mangadex::Upload

Inherits:
MangadexObject show all
Defined in:
lib/mangadex/upload.rb

Instance Attribute Summary

Attributes included from Internal::WithAttributes

#attributes, #id, #relationships, #type

Class Method Summary collapse

Methods inherited from MangadexObject

attributes_to_inspect, #eq?, #hash, #initialize, #inspect

Constructor Details

This class inherits a constructor from Mangadex::MangadexObject

Class Method Details

.abandon(upload_session_id) ⇒ Object Also known as: stop



39
40
41
42
43
# File 'lib/mangadex/upload.rb', line 39

def abandon(upload_session_id)
  Mangadex::Internal::Request.delete(
    '/upload/%{upload_session_id}' % {upload_session_id: upload_session_id},
  )
end

.commit(upload_session_id, **args) ⇒ Object



46
47
48
49
50
51
52
53
54
# File 'lib/mangadex/upload.rb', line 46

def commit(upload_session_id, **args)
  Mangadex::Internal::Request.post(
    '/upload/%{upload_session_id}/commit' % {upload_session_id: upload_session_id},
    payload: Mangadex::Internal::Definition.validate(args, {
      chapter_draft: { accepts: Hash }, # todo enforce chapter_draft content?
      page_order: { accepts: [String] },
    }),
  )
end

.currentObject



13
14
15
16
17
# File 'lib/mangadex/upload.rb', line 13

def current
  Mangadex::Internal::Request.get(
    '/upload',
  )
end

.delete_uploaded_image(upload_session_id, upload_session_file_id) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/mangadex/upload.rb', line 56

def delete_uploaded_image(upload_session_id, upload_session_file_id)
  Mangadex::Internal::Request.delete(
    '/upload/%{upload_session_id}/%{upload_session_file_id}' % {
      upload_session_id: upload_session_id,
      upload_session_file_id: upload_session_file_id,
    },
  )
end

.delete_uploaded_images(upload_session_id, upload_session_file_ids) ⇒ Object



65
66
67
68
69
70
# File 'lib/mangadex/upload.rb', line 65

def delete_uploaded_images(upload_session_id, upload_session_file_ids)
  Mangadex::Internal::Request.delete(
    '/upload/%{upload_session_id}' % {upload_session_id: upload_session_id},
    payload: Array(upload_session_file_id),
  )
end

.inspect_attributesObject



73
74
75
# File 'lib/mangadex/upload.rb', line 73

def self.inspect_attributes
  [:is_committed, :is_processed, :is_deleted]
end

.start(**args) ⇒ Object Also known as: begin



19
20
21
22
23
24
25
26
27
# File 'lib/mangadex/upload.rb', line 19

def start(**args)
  Mangadex::Internal::Request.post(
    '/upload/begin',
    payload: Mangadex::Internal::Definition.validate(args, {
      groups: { accepts: [String], required: true },
      manga: { accepts: String, required: true },
    }),
  )
end

.upload_images(upload_session_id) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/mangadex/upload.rb', line 30

def upload_images(upload_session_id)
  Mangadex::Internal::Request.post(
    '/upload/%{upload_session_id}' % {upload_session_id: upload_session_id},
    payload: Mangadex::Internal::Definition.validate(args, {
      file: { accepts: String },
    }),
  )
end