Class: Mangadex::User
Instance Attribute Summary
#attributes, #id, #related_type, #relationships, #type
Class Method Summary
collapse
#eq?, #hash, #initialize, #inspect
Methods included from Concern
#append_features, #class_methods, extended, #included, #prepend_features, #prepended
Class Method Details
.attributes_to_inspect ⇒ Object
174
175
176
|
# File 'lib/mangadex/user.rb', line 174
def self.attributes_to_inspect
[:username, :roles]
end
|
70
71
72
73
74
75
|
# File 'lib/mangadex/user.rb', line 70
def self.current
Mangadex::Internal::Request.get(
'/user/me',
auth: true,
)
end
|
.delete_code(code) ⇒ Object
40
41
42
43
44
|
# File 'lib/mangadex/user.rb', line 40
def self.delete_code(code)
Mangadex::Internal::Request.post(
"/user/delete/#{code}",
)
end
|
.followed_groups(**args) ⇒ Object
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/mangadex/user.rb', line 88
def self.followed_groups(**args)
Mangadex::Internal::Request.get(
'/user/follows/group',
Mangadex::Internal::Definition.validate(args, {
limit: { accepts: Integer, converts: :to_i },
offset: { accepts: Integer, converts: :to_i },
includes: { accepts: Array },
}),
auth: true,
)
end
|
.followed_manga(**args) ⇒ Object
145
146
147
148
149
150
151
152
153
154
155
|
# File 'lib/mangadex/user.rb', line 145
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
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/mangadex/user.rb', line 116
def self.followed_users(**args)
Mangadex::Internal::Request.get(
'/user/follows/user',
Mangadex::Internal::Definition.validate(args, {
limit: { accepts: Integer, converts: :to_i },
offset: { accepts: Integer, converts: :to_i },
}),
auth: true,
)
end
|
.follows_group(id) ⇒ Object
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/mangadex/user.rb', line 101
def self.follows_group(id)
Mangadex::Internal::Definition.must(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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
# File 'lib/mangadex/user.rb', line 158
def self.follows_manga(id)
Mangadex::Internal::Definition.must(id)
return if Mangadex.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
# File 'lib/mangadex/user.rb', line 128
def self.follows_user(id)
Mangadex::Internal::Definition.must(id)
return if Mangadex.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
|
.list(**args) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/mangadex/user.rb', line 10
def self.list(**args)
Mangadex::Internal::Request.get(
'/user',
Mangadex::Internal::Definition.validate(args, {
limit: { accepts: Integer, converts: :to_i },
offset: { accepts: Integer, converts: :to_i },
ids: { accepts: Array },
username: { accepts: String },
order: { accepts: Hash },
}),
auth: true,
)
end
|
.update_email(email:) ⇒ Object
61
62
63
64
65
66
67
|
# File 'lib/mangadex/user.rb', line 61
def self.update_email(email:)
Mangadex::Internal::Request.post(
'/user/email',
payload: { email: email },
auth: true,
)
end
|
.update_password(old_password:, new_password:) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/mangadex/user.rb', line 47
def self.update_password(old_password:, new_password:)
payload = {
oldPassword: old_password,
newPassword: new_password,
}
Mangadex::Internal::Request.post(
'/user/password',
payload: payload,
auth: true,
)
end
|