Class: Hiya::Users::Links
Instance Attribute Summary
Attributes inherited from Base
#api_url, #bearer_token, #response, #source
Instance Method Summary collapse
- #all ⇒ Object
- #analytics(code) ⇒ Object
-
#attach_files(code, files) ⇒ Object
code: a2e1M files: Array: [‘/path/to/file1’, ‘/path/to/file2’, …].
-
#destroy(code) ⇒ Object
code: a2e1M.
- #find(code) ⇒ Object
-
#update(code, params) ⇒ Object
code: a2e1M params: Hash: { attach: Hash: { password: String: ‘1234’ password_note: String: ‘today’ view_count_limit: Integer: 100 } post: Hash: { content: String: ‘This is post content’ } }.
-
#update_code(code, params) ⇒ Object
code: a2e1M params: Hash: { new_code: String: ‘TheAvengersEndGame’ }.
-
#update_ip_info(code, params) ⇒ Object
code: a2e1M params: Hash: { ip: String: “125.227.100.100”, hostname: String: “125-227-100-100.hinet-ip.hinet.net”, city: String: “Taipei”, region: String: “Taiwan”, country: String: “TW”, loc: String: “25.0418,121.5359”, org: String: “AS3462 Data Communication Business Group”, timezone: String: “Asia/Taipei” }.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Hiya::Base
Instance Method Details
#all ⇒ Object
6 7 8 9 10 11 |
# File 'lib/hiya/users/links.rb', line 6 def all @response = conn.get('/v1/users/links') Oj.load(response.body, symbol_keys: true) rescue StandardError => _e {} end |
#analytics(code) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/hiya/users/links.rb', line 20 def analytics(code) @response = conn.get("/v1/users/links/#{code}/analytics") Oj.load(response.body, symbol_keys: true) rescue StandardError => _e {} end |
#attach_files(code, files) ⇒ Object
code: a2e1M files: Array: [‘/path/to/file1’, ‘/path/to/file2’, …]
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/hiya/users/links.rb', line 29 def attach_files(code, files) return unless files.is_a?(Array) @files = files @response = multipart_conn.post("/v1/users/links/#{code}") do |req| req.body = attach_file_params end Oj.load(response.body, symbol_keys: true) rescue StandardError => _e {} end |
#destroy(code) ⇒ Object
code: a2e1M
96 97 98 99 100 101 |
# File 'lib/hiya/users/links.rb', line 96 def destroy(code) @response = conn.delete("/v1/users/links/#{code}") Oj.load(response.body, symbol_keys: true) rescue StandardError => _e {} end |
#find(code) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/hiya/users/links.rb', line 13 def find(code) @response = conn.get("/v1/users/links/#{code}") Oj.load(response.body, symbol_keys: true) rescue StandardError => _e {} end |
#update(code, params) ⇒ Object
code: a2e1M params: Hash: {
attach: Hash: {
password: String: '1234'
password_note: String: 'today'
view_count_limit: Integer: 100
}
post: Hash: {
content: String: 'This is post content'
}
}
53 54 55 56 57 58 59 60 |
# File 'lib/hiya/users/links.rb', line 53 def update(code, params) @response = conn.put("/v1/users/links/#{code}") do |req| req.body = params.to_json end Oj.load(response.body, symbol_keys: true) rescue StandardError => _e {} end |
#update_code(code, params) ⇒ Object
code: a2e1M params: Hash:
new_code: String: 'TheAvengersEndGame'
66 67 68 69 70 71 72 73 |
# File 'lib/hiya/users/links.rb', line 66 def update_code(code, params) @response = conn.put("/v1/users/links/#{code}/code") do |req| req.body = params.to_json end Oj.load(response.body, symbol_keys: true) rescue StandardError => _e {} end |
#update_ip_info(code, params) ⇒ Object
code: a2e1M params: Hash:
ip: String: "125.227.100.100",
hostname: String: "125-227-100-100.hinet-ip.hinet.net",
city: String: "Taipei",
region: String: "Taiwan",
country: String: "TW",
loc: String: "25.0418,121.5359",
org: String: "AS3462 Data Communication Business Group",
timezone: String: "Asia/Taipei"
86 87 88 89 90 91 92 93 |
# File 'lib/hiya/users/links.rb', line 86 def update_ip_info(code, params) @response = conn.post("/v1/users/links/#{code}/ip_info") do |req| req.body = params.to_json end Oj.load(response.body, symbol_keys: true) rescue StandardError => _e {} end |