class EasyCodef::Codef

Codef 클래스 요청에 필요한 설정 값들을 가지고 있으며 유저의 요청 파라미터에 따라 실제 API를 요청하는 역할을 한다

Public Class Methods

new(public_key='') click to toggle source
# File lib/easycodefrb/easycodef.rb, line 63
def initialize(public_key='')
  @access_token = AccessToken.new()
  @demo_client_id = ''
  @demo_client_secret = ''
  @client_id = ''
  @client_secret = ''
  @public_key = public_key
end

Public Instance Methods

access_token() click to toggle source
# File lib/easycodefrb/easycodef.rb, line 100
def access_token
  return @access_token
end
add_account(service_type, param) click to toggle source

계정 정보 추가

# File lib/easycodefrb/easycodef.rb, line 225
def add_account(service_type, param)
  return request_product(PATH_ADD_ACCOUNT, service_type, param)
end
client_id() click to toggle source
# File lib/easycodefrb/easycodef.rb, line 92
def client_id
  return @client_id
end
client_secret() click to toggle source
# File lib/easycodefrb/easycodef.rb, line 96
def client_secret
  return @client_secret
end
create_account(service_type, param) click to toggle source

connectedID 발급을 위한 계정 등록

# File lib/easycodefrb/easycodef.rb, line 220
def create_account(service_type, param)
  return request_product(PATH_CREATE_ACCOUNT, service_type, param)
end
delete_account(service_type, param) click to toggle source

계정 정보 삭제

# File lib/easycodefrb/easycodef.rb, line 235
def delete_account(service_type, param)
  return request_product(PATH_DELETE_ACCOUNT, service_type, param)
end
demo_client_id() click to toggle source
# File lib/easycodefrb/easycodef.rb, line 84
def demo_client_id
  return @demo_client_id
end
demo_client_secret() click to toggle source
# File lib/easycodefrb/easycodef.rb, line 88
def demo_client_secret
  return @demo_client_secret
end
get_account_list(service_type, param) click to toggle source

connectedID로 등록된 계정 목록 조회

# File lib/easycodefrb/easycodef.rb, line 240
def get_account_list(service_type, param)
  return request_product(PATH_GET_ACCOUNT_LIST, service_type, param)
end
get_connected_id_list(service_type, param) click to toggle source

클라이언트 정보로 등록된 모든 connectedID 목록 조회

# File lib/easycodefrb/easycodef.rb, line 245
def get_connected_id_list(service_type, param)
  return request_product(PATH_GET_CID_LIST, service_type, param)
end
get_req_info_by_service_type(service_type) click to toggle source

서비스 타입에 해당하는 요청 정보 객체 가져오기

# File lib/easycodefrb/easycodef.rb, line 111
def get_req_info_by_service_type(service_type)
  return case service_type
  when TYPE_PRODUCT
    RequestInfo.new(
      API_DOMAIN,
      @client_id,
      @client_secret
    )
  when TYPE_DEMO
    RequestInfo.new(
      DEMO_DOMAIN,
      @demo_client_id,
      @demo_client_secret
    )
  else
    RequestInfo.new(
      SANDBOX_DOMAIN,
      SANDBOX_CLIENT_ID,
      SANDBOX_CLIENT_SECRET
    )
  end
end
public_key(public_key=nil) click to toggle source
# File lib/easycodefrb/easycodef.rb, line 104
def public_key (public_key=nil)
  @public_key = public_key if public_key
  return @public_key
end
request_certification(product_path, service_type, param) click to toggle source

상품 추가인증 요청

# File lib/easycodefrb/easycodef.rb, line 170
def request_certification(product_path, service_type, param)
  # 클라이언트 정보 검사
  if !has_client_info(service_type)
    res = new_response_message(Message::EMPTY_CLIENT_INFO)
    return res.to_json()
  end

  # 퍼블릭키 검사
  if @public_key == ''
    res = new_response_message(Message::EMPTY_PUBLIC_KEY)
    return res.to_json()
  end

  # 추가인증 파라미터 필수 입력 체크
  if !has_require_two_way_info(param)
    res = new_response_message(Message::INVALID_2WAY_INFO)
    return res.to_json()
  end
  
  # 리퀘스트 정보 조회
  req_info = get_req_info_by_service_type(service_type)

  # 요청
  res = Connector.execute(
    product_path,
    param,
    @access_token,
    req_info,
    service_type
  )
  return res.to_json()
end
request_product(product_path, service_type, param) click to toggle source

API 요청

# File lib/easycodefrb/easycodef.rb, line 135
def request_product(product_path, service_type, param)

  # 클라이언트 정보 검사
  if !has_client_info(service_type)
    res = new_response_message(Message::EMPTY_CLIENT_INFO)
    return res.to_json()
  end

  # 퍼블릭키 검사
  if @public_key == ''
    res = new_response_message(Message::EMPTY_PUBLIC_KEY)
    return res.to_json()
  end

  # 추가인증 키워드 비어있는지 체크
  if !is_empty_two_way_keyword(param)
    res = new_response_message(Message::INVALID_2WAY_KEYWORD)
    return res.to_json()
  end

  # 리퀘스트 정보 조회
  req_info = get_req_info_by_service_type(service_type)

  # 요청
  res = Connector.execute(
    product_path,
    param,
    @access_token,
    req_info,
    service_type
  )
  return res.to_json()
end
request_token(service_type) click to toggle source

토큰 요청

# File lib/easycodefrb/easycodef.rb, line 204
def request_token(service_type)
  if !has_client_info(service_type)
    return nil
  end

  return case service_type
  when TYPE_PRODUCT
    Connector.request_token(@client_id, @client_secret)
  when TYPE_DEMO
    Connector.request_token(@demo_client_id, @demo_client_secret)
  else 
    Connector.request_token(SANDBOX_CLIENT_ID, SANDBOX_CLIENT_SECRET)
  end
end
set_client_info(id, secret) click to toggle source

정식버전 클라이언트 정보 셋팅

# File lib/easycodefrb/easycodef.rb, line 73
def set_client_info(id, secret)
  @client_id = id
  @client_secret = secret
end
set_client_info_for_demo(id, secret) click to toggle source

데모버전 클라이언트 정보 셋팅

# File lib/easycodefrb/easycodef.rb, line 79
def set_client_info_for_demo(id, secret)
  @demo_client_id = id
  @demo_client_secret = secret
end
update_account(service_type, param) click to toggle source

계정 정보 수정

# File lib/easycodefrb/easycodef.rb, line 230
def update_account(service_type, param)
  return request_product(PATH_UPDATE_ACCOUNT, service_type, param)
end

Private Instance Methods

has_client_info(service_type) click to toggle source

클라이언트 정보 검사

# File lib/easycodefrb/easycodef.rb, line 252
def has_client_info(service_type)
  return case service_type
  when TYPE_PRODUCT
    @client_id.strip != '' && client_secret.strip != ''
  when TYPE_DEMO
    @demo_client_id.strip != '' && @demo_client_secret.strip != ''
  else
    SANDBOX_CLIENT_ID.strip != '' && SANDBOX_CLIENT_SECRET.strip != ''
  end
end