Class: Mangadex::User

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

Instance Attribute Summary

Attributes included from Internal::WithAttributes

#attributes, #id, #relationships, #type

Class Method Summary collapse

Methods inherited from MangadexObject

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

Constructor Details

This class inherits a constructor from Mangadex::MangadexObject

Class Method Details

.attributes_to_inspectObject



99
100
101
# File 'lib/mangadex/user.rb', line 99

def self.attributes_to_inspect
  [:username, :roles]
end

.feed(**args) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/mangadex/user.rb', line 10

def self.feed(**args)
  Mangadex::Internal::Request.get(
    '/user/follows/manga/feed',
    Mangadex::Internal::Definition.chapter_list(args),
    auth: true,
  )
end

.followed_groups(**args) ⇒ Object



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

def self.followed_groups(**args)
  Mangadex::Internal::Request.get(
    '/user/follows/group',
    Mangadex::Internal::Definition.validate(args, {
      limit: { accepts: Integer },
      offset: { accepts: Integer },
      includes: { accepts: Array },
    }),
    auth: true,
  )
end

.followed_manga(**args) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/mangadex/user.rb', line 72

def self.followed_manga(**args)
  Mangadex::Internal::Request.get(
    '/user/follows/manga',
    Mangadex::Internal::Definition.validate(args, {
      limit: { accepts: Integer },
      offset: { accepts: Integer },
      includes: { accepts: Array },
    }),
    auth: true,
  )
end

.followed_users(**args) ⇒ Object



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

def self.followed_users(**args)
  Mangadex::Internal::Request.get(
    '/user/follows/user',
    Mangadex::Internal::Definition.validate(args, {
      limit: { accepts: Integer },
      offset: { accepts: Integer },
    }),
    auth: true,
  )
end

.follows_group(id) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/mangadex/user.rb', line 32

def self.follows_group(id)
  data = Mangadex::Internal::Request.get(
    '/user/follows/group/%{id}' % {id: id},
    raw: true,
    auth: true,
  )
  JSON.parse(data)['result'] == 'ok'
rescue JSON::ParserError => error
  warn(error)
  false
end

.follows_manga(id) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/mangadex/user.rb', line 85

def self.follows_manga(id)
  return if Mangadex::Api::Context.user.nil?

  data = Mangadex::Internal::Request.get(
    '/user/follows/manga/%{id}' % {id: id},
    raw: true,
    auth: true,
  )
  JSON.parse(data)['result'] == 'ok'
rescue JSON::ParserError => error
  warn(error)
  false
end

.follows_user(id) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/mangadex/user.rb', line 57

def self.follows_user(id)
  return if Mangadex::Api::Context.user.nil?

  data = Mangadex::Internal::Request.get(
    '/user/follows/user/%{id}' % {id: id},
    raw: true,
    auth: true,
  )
  JSON.parse(data)['result'] == 'ok'
rescue JSON::ParserError => error
  warn(error)
  false
end