Module: JPush::Http::Client

Extended by:
Client
Included in:
Client
Defined in:
lib/jpush/http/client.rb

Instance Method Summary collapse

Instance Method Details

#delete(url, params: nil, headers: {}) ⇒ Object



20
21
22
# File 'lib/jpush/http/client.rb', line 20

def delete(url, params: nil, headers: {})
  send_request(:delete, url, params: params, headers: headers)
end

#get(url, params: nil, headers: {}) ⇒ Object



8
9
10
# File 'lib/jpush/http/client.rb', line 8

def get(url, params: nil, headers: {})
  send_request(:get, url, params: params, headers: headers)
end

#post(url, body:, headers: {}) ⇒ Object



12
13
14
# File 'lib/jpush/http/client.rb', line 12

def post(url, body: , headers: {})
  send_request(:post, url, body: body, headers: headers)
end

#put(url, body:, headers: {}) ⇒ Object



16
17
18
# File 'lib/jpush/http/client.rb', line 16

def put(url, body: , headers: {})
  send_request(:put, url, body: body, headers: headers)
end

#send_request(method, url, params: nil, body: nil, headers: {}, opts: {}) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/jpush/http/client.rb', line 24

def send_request(method, url, params: nil, body: nil, headers: {}, opts: {})
  raw_response = Utils::Http.new(
    method.to_sym,
    url,
    params: params,
    body: body,
    headers: headers,
    opts: opts
  ).basic_auth.send_request

  Response.new(raw_response)
end