Class: Lark::Api
Instance Attribute Summary collapse
-
#app_id ⇒ Object
readonly
Returns the value of attribute app_id.
-
#app_secret ⇒ Object
readonly
Returns the value of attribute app_secret.
-
#isv ⇒ Object
readonly
Returns the value of attribute isv.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#tenant_key ⇒ Object
readonly
Returns the value of attribute tenant_key.
Class Method Summary collapse
Instance Method Summary collapse
- #app_access_token ⇒ Object
- #app_ticket ⇒ Object
- #app_ticket=(new_ticket) ⇒ Object
- #get(path, headers = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Api
constructor
A new instance of Api.
- #post(path, payload, headers = {}) ⇒ Object
- #post_file(path, file, headers = {}) ⇒ Object
- #request ⇒ Object
- #tenant_access_token ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Api
Returns a new instance of Api.
27 28 29 30 31 32 33 34 35 |
# File 'lib/lark/api.rb', line 27 def initialize( = {}) @app_id = .delete(:app_id) || Lark.config.default_app_id @app_secret = .delete(:app_secret) || Lark.config.default_app_secret raise AppNotConfigException if @app_id.nil? || @app_id.empty? @tenant_key = .delete(:tenant_key) @isv = .delete(:isv) || Lark.config.default_isv @options = end |
Instance Attribute Details
#app_id ⇒ Object (readonly)
Returns the value of attribute app_id.
25 26 27 |
# File 'lib/lark/api.rb', line 25 def app_id @app_id end |
#app_secret ⇒ Object (readonly)
Returns the value of attribute app_secret.
25 26 27 |
# File 'lib/lark/api.rb', line 25 def app_secret @app_secret end |
#isv ⇒ Object (readonly)
Returns the value of attribute isv.
25 26 27 |
# File 'lib/lark/api.rb', line 25 def isv @isv end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
25 26 27 |
# File 'lib/lark/api.rb', line 25 def @options end |
#tenant_key ⇒ Object (readonly)
Returns the value of attribute tenant_key.
25 26 27 |
# File 'lib/lark/api.rb', line 25 def tenant_key @tenant_key end |
Class Method Details
Instance Method Details
#app_access_token ⇒ Object
71 72 73 |
# File 'lib/lark/api.rb', line 71 def app_access_token app_token_store.token end |
#app_ticket ⇒ Object
67 68 69 |
# File 'lib/lark/api.rb', line 67 def app_ticket Lark.redis.get "APP_TICKET_#{app_id}" end |
#app_ticket=(new_ticket) ⇒ Object
63 64 65 |
# File 'lib/lark/api.rb', line 63 def app_ticket=(new_ticket) Lark.redis.set "APP_TICKET_#{app_id}", new_ticket end |
#get(path, headers = {}) ⇒ Object
45 46 47 48 49 |
# File 'lib/lark/api.rb', line 45 def get(path, headers = {}) with_token(headers) do |headers_with_token| request.get path, headers_with_token end end |
#post(path, payload, headers = {}) ⇒ Object
51 52 53 54 55 |
# File 'lib/lark/api.rb', line 51 def post(path, payload, headers = {}) with_token(headers) do |headers_with_token| request.post path, payload, headers_with_token end end |
#post_file(path, file, headers = {}) ⇒ Object
57 58 59 60 61 |
# File 'lib/lark/api.rb', line 57 def post_file(path, file, headers = {}) with_token(headers) do |headers_with_token| request.post_file path, file, headers_with_token end end |
#request ⇒ Object
41 42 43 |
# File 'lib/lark/api.rb', line 41 def request @request ||= Lark::Request.new end |
#tenant_access_token ⇒ Object
75 76 77 |
# File 'lib/lark/api.rb', line 75 def tenant_access_token tenant_token_store.token end |
#valid? ⇒ Boolean
37 38 39 |
# File 'lib/lark/api.rb', line 37 def valid? app_token_store.valid? && tenant_token_store.valid? end |