Class: Mangadex::ScanlationGroup

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

Instance Attribute Summary

Attributes included from Internal::WithAttributes

#attributes, #id, #related_type, #relationships, #type

Class Method Summary collapse

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

.create(**args) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/mangadex/scanlation_group.rb', line 40

def create(**args)
  Mangadex::Internal::Request.post(
    '/group',
    payload: Mangadex::Internal::Definition.validate(args, {
      name: { accepts: String, required: true },
      website: { accepts: String },
      irc_server: { accepts: String },
      irc_channel: { accepts: String },
      discord: { accepts: String },
      contact_email: { accepts: String },
      description: { accepts: String },
    }),
  )
end

.delete(id) ⇒ Object



83
84
85
86
87
# File 'lib/mangadex/scanlation_group.rb', line 83

def delete(id)
  Mangadex::Internal::Request.delete(
    '/group/%{id}' % {id: id},
  )
end

.follow(id) ⇒ Object



89
90
91
92
93
# File 'lib/mangadex/scanlation_group.rb', line 89

def follow(id)
  Mangadex::Internal::Request.post(
    '/group/%{id}/follow' % {id: id},
  )
end

.inspect_attributesObject



107
108
109
# File 'lib/mangadex/scanlation_group.rb', line 107

def self.inspect_attributes
  self.attributes - [:version, :created_at, :updated_at]
end

.list(**args) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/mangadex/scanlation_group.rb', line 27

def list(**args)
  Mangadex::Internal::Request.get(
    '/group',
    Mangadex::Internal::Definition.validate(args, {
      limit: { accepts: Integer, converts: :to_i },
      offset: { accepts: Integer, converts: :to_i },
      ids: { accepts: [String], converts: :to_a },
      name: { accepts: String },
      includes: { accepts: [String], converts: :to_a },
    }),
  )
end

.unfollow(id) ⇒ Object



95
96
97
98
99
# File 'lib/mangadex/scanlation_group.rb', line 95

def unfollow(id)
  Mangadex::Internal::Request.delete(
    '/group/%{id}/follow' % {id: id},
  )
end

.update(id, **args) ⇒ Object Also known as: edit



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/mangadex/scanlation_group.rb', line 66

def update(id, **args)
  Mangadex::Internal::Request.put(
    '/group/%{id}' % {id: id},
    payload: Mangadex::Internal::Definition.validate(args, {
      name: { accepts: String },
      website: { accepts: String },
      irc_server: { accepts: String },
      irc_channel: { accepts: String },
      discord: { accepts: String },
      contact_email: { accepts: String },
      description: { accepts: String },
      locked: { accepts: [true, false] },
      version: { accepts: Integer, required: true },
    }),
  )
end

.view(id) ⇒ Object Also known as: get



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

def view(id)
  Mangadex::Internal::Definition.must(id)

  Mangadex::Internal::Request.get(
    '/group/%{id}' % {id: id},
    Mangadex::Internal::Definition.validate(args, {
      includes: { accepts: [String], converts: :to_a },
    }),
  )
end