Module: Memobird

Defined in:
lib/memobird.rb,
lib/memobird/version.rb

Overview

Memobird API wrapper

Constant Summary collapse

HOST =
'http://open.memobird.cn/home'.freeze
API_RETRIEVE_USER_ID =
"#{HOST}/setuserbind".freeze
API_PRINT_CONTENT =
"#{HOST}/printpaper".freeze
VERSION =
'0.1.0'.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_keyObject

Returns the value of attribute api_key.



15
16
17
# File 'lib/memobird.rb', line 15

def api_key
  @api_key
end

.memobird_idObject

Returns the value of attribute memobird_id.



15
16
17
# File 'lib/memobird.rb', line 15

def memobird_id
  @memobird_id
end

.user_idObject

Returns the value of attribute user_id.



15
16
17
# File 'lib/memobird.rb', line 15

def user_id
  @user_id
end

.user_identifyingObject

Returns the value of attribute user_identifying.



15
16
17
# File 'lib/memobird.rb', line 15

def user_identifying
  @user_identifying
end

Class Method Details



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/memobird.rb', line 17

def print_content(content = {})
  raise 'Please set up first' if not_ready?
  load_user_id if user_id.nil?
  puts content
  response = http_get(build_url(API_PRINT_CONTENT,
                                userid: user_id,
                                printcontent: build_print_content(content)))
  puts response['showapi_res_error'].to_s + ' ' + response['printcontentid'].to_s
rescue StandardError => e
  puts 'Print content error. ' + e.message
end