Class: Sendgo::HttpClient
- Inherits:
-
Object
- Object
- Sendgo::HttpClient
- Defined in:
- lib/sendgo/http_client.rb
Overview
Sendgo API HTTP 클라이언트.
Instance Method Summary collapse
-
#delete(path) ⇒ Object
DELETE 요청.
-
#get(path, params = {}) ⇒ Object
GET 요청.
-
#initialize(token_manager:, base_url:, api_version:) ⇒ HttpClient
constructor
A new instance of HttpClient.
- #patch(path, body) ⇒ Object
- #post(path, body) ⇒ Object
-
#post_multipart(path, fields = {}, files = {}) ⇒ Object
multipart/form-data POST — 서류·이미지 첨부가 있는 관리 API 전용.
- #put(path, body) ⇒ Object
Constructor Details
#initialize(token_manager:, base_url:, api_version:) ⇒ HttpClient
Returns a new instance of HttpClient.
9 10 11 12 13 |
# File 'lib/sendgo/http_client.rb', line 9 def initialize(token_manager:, base_url:, api_version:) @token_manager = token_manager @base_url = base_url @api_version = api_version end |
Instance Method Details
#delete(path) ⇒ Object
DELETE 요청. 짧은 URL 리다이렉트 중지에서 사용한다.
34 35 36 |
# File 'lib/sendgo/http_client.rb', line 34 def delete(path) request(:delete, path, is_retry: false) end |
#get(path, params = {}) ⇒ Object
GET 요청. 캠페인 조회 엔드포인트에서 사용한다. params 의 nil 값은 제외되어 서버 기본값이 적용된다.
21 22 23 |
# File 'lib/sendgo/http_client.rb', line 21 def get(path, params = {}) request(:get, path, params: params, is_retry: false) end |
#patch(path, body) ⇒ Object
29 30 31 |
# File 'lib/sendgo/http_client.rb', line 29 def patch(path, body) request(:patch, path, body: body, is_retry: false) end |
#post(path, body) ⇒ Object
15 16 17 |
# File 'lib/sendgo/http_client.rb', line 15 def post(path, body) request(:post, path, body: body, is_retry: false) end |
#post_multipart(path, fields = {}, files = {}) ⇒ Object
multipart/form-data POST — 서류·이미지 첨부가 있는 관리 API 전용.
발신번호 등록과 이미지 템플릿은 JSON 으로 보낼 수 없다. multipart 에는 배열도 불리언도 없으므로, Array/Hash 값은 JSON 문자열로 눌러 보낸다 — 서버가 그렇게 받아 읽는다.
files 는 { 필드명 => [파일명, IO 또는 문자열, content_type] } 형태다. 같은 필드에 여러 파일을 붙이려면 배열로 넘긴다.
46 47 48 |
# File 'lib/sendgo/http_client.rb', line 46 def post_multipart(path, fields = {}, files = {}) multipart_request(path, fields, files, is_retry: false) end |
#put(path, body) ⇒ Object
25 26 27 |
# File 'lib/sendgo/http_client.rb', line 25 def put(path, body) request(:put, path, body: body, is_retry: false) end |