Class: Mangadex::Upload
- Inherits:
-
MangadexObject
- Object
- MangadexObject
- Mangadex::Upload
- Defined in:
- lib/mangadex/upload.rb
Instance Attribute Summary
Attributes included from Internal::WithAttributes
#attributes, #id, #related_type, #relationships, #type
Class Method Summary collapse
- .abandon(upload_session_id) ⇒ Object (also: stop)
- .commit(upload_session_id, **args) ⇒ Object
- .current ⇒ Object
- .delete_uploaded_image(upload_session_id, upload_session_file_id) ⇒ Object
- .delete_uploaded_images(upload_session_id, upload_session_file_ids) ⇒ Object
- .inspect_attributes ⇒ Object
- .start(**args) ⇒ Object (also: begin)
- .upload_images(upload_session_id) ⇒ Object
Methods inherited from MangadexObject
attributes_to_inspect, #eq?, #hash, #initialize, #inspect
Methods included from Concern
#append_features, #class_methods, extended, #included, #prepend_features, #prepended
Constructor Details
This class inherits a constructor from Mangadex::MangadexObject
Class Method Details
.abandon(upload_session_id) ⇒ Object Also known as: stop
41 42 43 44 45 46 47 |
# File 'lib/mangadex/upload.rb', line 41 def abandon(upload_session_id) Mangadex::Internal::Definition.must(upload_session_id) Mangadex::Internal::Request.delete( '/upload/%{upload_session_id}' % {upload_session_id: upload_session_id}, ) end |
.commit(upload_session_id, **args) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/mangadex/upload.rb', line 50 def commit(upload_session_id, **args) Mangadex::Internal::Definition.must(upload_session_id) 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], converts: :to_a }, }), ) end |
.current ⇒ Object
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
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/mangadex/upload.rb', line 62 def delete_uploaded_image(upload_session_id, upload_session_file_id) Mangadex::Internal::Definition.must(upload_session_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
73 74 75 76 77 78 79 80 |
# File 'lib/mangadex/upload.rb', line 73 def delete_uploaded_images(upload_session_id, upload_session_file_ids) Mangadex::Internal::Definition.must(upload_session_id) Mangadex::Internal::Request.delete( '/upload/%{upload_session_id}' % {upload_session_id: upload_session_id}, payload: Array(upload_session_file_id), ) end |
.inspect_attributes ⇒ Object
83 84 85 |
# File 'lib/mangadex/upload.rb', line 83 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 38 39 |
# File 'lib/mangadex/upload.rb', line 30 def upload_images(upload_session_id) Mangadex::Internal::Definition.must(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 |