Class: Wechat::Api::Base
- Inherits:
-
Object
- Object
- Wechat::Api::Base
- Defined in:
- app/apis/wechat/api/base.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #get(path, params: {}, headers: {}, base: nil, as: nil) ⇒ Object
-
#initialize(app) ⇒ Base
constructor
A new instance of Base.
- #post(path, params: {}, headers: {}, base: nil, **payload) ⇒ Object
- #post_file(path, file, params: {}, headers: {}, base: nil) ⇒ Object
Constructor Details
#initialize(app) ⇒ Base
Returns a new instance of Base.
7 8 9 10 |
# File 'app/apis/wechat/api/base.rb', line 7 def initialize(app) @app = app @client = Wechat::HttpClient.new end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
5 6 7 |
# File 'app/apis/wechat/api/base.rb', line 5 def app @app end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'app/apis/wechat/api/base.rb', line 5 def client @client end |
Instance Method Details
#get(path, params: {}, headers: {}, base: nil, as: nil) ⇒ Object
12 13 14 15 16 |
# File 'app/apis/wechat/api/base.rb', line 12 def get(path, params: {}, headers: {}, base: nil, as: nil) with_access_token(params) do |with_token_params| @client.get path, headers: headers, params: with_token_params, base: base, as: as end end |
#post(path, params: {}, headers: {}, base: nil, **payload) ⇒ Object
18 19 20 21 22 |
# File 'app/apis/wechat/api/base.rb', line 18 def post(path, params: {}, headers: {}, base: nil, **payload) with_access_token(params) do |with_token_params| @client.post path, payload.to_json, headers: headers, params: with_token_params, base: base end end |
#post_file(path, file, params: {}, headers: {}, base: nil) ⇒ Object
24 25 26 27 28 |
# File 'app/apis/wechat/api/base.rb', line 24 def post_file(path, file, params: {}, headers: {}, base: nil) with_access_token(params) do |with_token_params| @client.post_file path, file, headers: headers, params: with_token_params, base: base end end |