Class: Hiya::AttachBase
Instance Attribute Summary
Attributes inherited from Base
#api_url, #bearer_token, #response, #source
Instance Method Summary collapse
-
#create(files, opts = {}) ⇒ Object
files: Array: [‘/path/to/file1’, ‘/path/to/file2’, …] opts: Hash: { attach: Hash: { password: String: ‘1234’ password_note: String: ‘today’ expired_num: Integer: 3600 view_count_limit: Integer: 100 } post: Hash: { content: String: ‘This is post content’ } }.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Hiya::Base
Instance Method Details
#create(files, opts = {}) ⇒ Object
files: Array: [‘/path/to/file1’, ‘/path/to/file2’, …] opts: Hash: {
attach: Hash: {
password: String: '1234'
password_note: String: 'today'
expired_num: Integer: 3600
view_count_limit: Integer: 100
}
post: Hash: {
content: String: 'This is post content'
}
}
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/hiya/attach_base.rb', line 19 def create(files, opts = {}) return unless files.is_a?(Array) @files = files @opts = opts @response = multipart_conn.post(url) do |req| req.body = create_params end Oj.load(response.body, symbol_keys: true) rescue StandardError => _e {} end |