Class: Yookassa::Client
- Inherits:
-
Object
- Object
- Yookassa::Client
- Defined in:
- lib/yookassa/client.rb
Constant Summary collapse
- API_URL =
"https://api.yookassa.ru/v3/"
Instance Attribute Summary collapse
-
#http ⇒ Object
readonly
Returns the value of attribute http.
Instance Method Summary collapse
- #get(endpoint, query: {}) ⇒ Object
-
#initialize(shop_id:, api_key:) ⇒ Client
constructor
A new instance of Client.
- #payments ⇒ Object
- #post(endpoint, idempotency_key:, payload: {}) ⇒ Object
- #refunds ⇒ Object
Constructor Details
#initialize(shop_id:, api_key:) ⇒ Client
Returns a new instance of Client.
14 15 16 |
# File 'lib/yookassa/client.rb', line 14 def initialize(shop_id:, api_key:) @http = HTTP.basic_auth(user: shop_id, pass: api_key).headers(accept: "application/json") end |
Instance Attribute Details
#http ⇒ Object (readonly)
Returns the value of attribute http.
12 13 14 |
# File 'lib/yookassa/client.rb', line 12 def http @http end |
Instance Method Details
#get(endpoint, query: {}) ⇒ Object
26 27 28 |
# File 'lib/yookassa/client.rb', line 26 def get(endpoint, query: {}) api_call { http.get("#{API_URL}#{endpoint}", params: query) } end |
#payments ⇒ Object
18 19 20 |
# File 'lib/yookassa/client.rb', line 18 def payments @payments ||= Payments.new(self) end |
#post(endpoint, idempotency_key:, payload: {}) ⇒ Object
30 31 32 |
# File 'lib/yookassa/client.rb', line 30 def post(endpoint, idempotency_key:, payload: {}) api_call { http.headers("Idempotence-Key" => idempotency_key).post("#{API_URL}#{endpoint}", json: payload) } end |