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



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

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



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

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

.follow(id) ⇒ Object



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

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

.inspect_attributesObject



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

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

.list(**args) ⇒ Object



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

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



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

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

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



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

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



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

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