Module: Sendgo::Rails

Defined in:
lib/sendgo/rails.rb,
lib/sendgo/rails/railtie.rb,
lib/sendgo/rails/version.rb

Overview

Rails 통합 모듈.

Rails.application.config.sendgo(ActiveSupport::OrderedOptions) 설정을 우선 사용하고, 값이 없으면 ENV 환경변수로 폴백하여 Sendgo::Client를 생성한다.

Examples:

컨트롤러에서 사용

Sendgo::Rails.client.alimtalk.send(
  template_code: "ORDER_CONFIRM_001",
  contacts: [{ contact: "01012345678", var1: "ORD-001" }]
)

브랜드메시지 (친구톡의 후속 채널, v2 전용)

Sendgo::Rails.client.brand_message.send(
  targeting: "M",
  message_type: "FL",
  friend_template_uuid: "9cd5460b-6458-4edc-9b11-c26d3013c340",
  contacts: [{ contact: "01012345678", var1: "29,000원" }]
)

Defined Under Namespace

Classes: Railtie

Constant Summary collapse

VERSION =

sendgo-rails 젬 버전

"1.1.0"

Class Method Summary collapse

Class Method Details

.clientSendgo::Client

메모이즈된 Sendgo::Client 인스턴스를 반환한다.

Returns:

  • (Sendgo::Client)


32
33
34
# File 'lib/sendgo/rails.rb', line 32

def client
  @client ||= build_client
end

.reset!void

This method returns an undefined value.

메모이즈된 클라이언트를 초기화한다. (주로 테스트에서 사용)



39
40
41
# File 'lib/sendgo/rails.rb', line 39

def reset!
  @client = nil
end