Class: Sendgo::KakaoImageService
- Inherits:
-
Object
- Object
- Sendgo::KakaoImageService
- Defined in:
- lib/sendgo/management.rb
Overview
카카오 이미지 업로드 — 브랜드메시지 템플릿에 넣을 URL 발급.
v2 전용, 기업 계정 전용. 브랜드메시지 템플릿의 imageUrl 은 아무 URL 이나
되는 게 아니라 카카오가 호스팅하는 URL 이어야 하고, 그 URL 을 얻는
방법이 이 업로드뿐이다.
Constant Summary collapse
- RESOURCE =
"kakao-images"- SINGLE_TYPES =
파일 하나를 올리고 URL 하나를 받는 유형.
%w[alimtalk alimtalk_highlight default wide wide_item_list_first].freeze
- MULTI_TYPES =
파일 여러 개를 올리는 유형과 최대 개수.
{ "wide_item_list" => 4, "carousel_feed" => 10, "carousel_commerce" => 11 }.freeze
Instance Method Summary collapse
-
#initialize(http:) ⇒ KakaoImageService
constructor
A new instance of KakaoImageService.
-
#types ⇒ Object
업로드 가능한 유형과 제약.
-
#upload(image_type, image) ⇒ Object
단일 이미지 업로드.
-
#upload_many(image_type, images) ⇒ Object
다중 이미지 업로드.
Constructor Details
#initialize(http:) ⇒ KakaoImageService
Returns a new instance of KakaoImageService.
552 553 554 |
# File 'lib/sendgo/management.rb', line 552 def initialize(http:) @http = http end |
Instance Method Details
#types ⇒ Object
업로드 가능한 유형과 제약.
557 558 559 |
# File 'lib/sendgo/management.rb', line 557 def types @http.get("#{RESOURCE}/types") end |
#upload(image_type, image) ⇒ Object
단일 이미지 업로드. jpg/png, 2MB 이하. data.imageUrl 을 받는다.
562 563 564 |
# File 'lib/sendgo/management.rb', line 562 def upload(image_type, image) @http.post_multipart(path(image_type), {}, { image: image }) end |
#upload_many(image_type, images) ⇒ Object
다중 이미지 업로드. 유형별 최대 개수가 다르다.
567 568 569 |
# File 'lib/sendgo/management.rb', line 567 def upload_many(image_type, images) @http.post_multipart(path(image_type), {}, { images: images }) end |