Class: EasyCodef::Codef
- Inherits:
-
Object
- Object
- EasyCodef::Codef
- Defined in:
- lib/easycodefrb/easycodef.rb
Overview
Codef 클래스요청에 필요한 설정 값들을 가지고 있으며유저의 요청 파라미터에 따라 실제 API를 요청하는 역할을 한다
Instance Method Summary collapse
- #access_token ⇒ Object
-
#add_account(service_type, param) ⇒ Object
계정 정보 추가.
- #client_id ⇒ Object
- #client_secret ⇒ Object
-
#create_account(service_type, param) ⇒ Object
connectedID 발급을 위한 계정 등록.
-
#delete_account(service_type, param) ⇒ Object
계정 정보 삭제.
- #demo_client_id ⇒ Object
- #demo_client_secret ⇒ Object
-
#get_account_list(service_type, param) ⇒ Object
connectedID로 등록된 계정 목록 조회.
-
#get_connected_id_list(service_type, param) ⇒ Object
클라이언트 정보로 등록된 모든 connectedID 목록 조회.
-
#get_req_info_by_service_type(service_type) ⇒ Object
서비스 타입에 해당하는 요청 정보 객체 가져오기.
-
#initialize(public_key = '') ⇒ Codef
constructor
A new instance of Codef.
- #public_key(public_key = nil) ⇒ Object
-
#request_certification(product_path, service_type, param) ⇒ Object
상품 추가인증 요청.
-
#request_product(product_path, service_type, param) ⇒ Object
API 요청.
-
#request_token(service_type) ⇒ Object
토큰 요청.
-
#set_client_info(id, secret) ⇒ Object
정식버전 클라이언트 정보 셋팅.
-
#set_client_info_for_demo(id, secret) ⇒ Object
데모버전 클라이언트 정보 셋팅.
-
#update_account(service_type, param) ⇒ Object
계정 정보 수정.
Constructor Details
#initialize(public_key = '') ⇒ Codef
Returns a new instance of Codef.
63 64 65 66 67 68 69 70 |
# 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 |
Instance Method Details
#access_token ⇒ Object
100 101 102 |
# File 'lib/easycodefrb/easycodef.rb', line 100 def access_token return @access_token end |
#add_account(service_type, param) ⇒ Object
계정 정보 추가
225 226 227 |
# 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 ⇒ Object
92 93 94 |
# File 'lib/easycodefrb/easycodef.rb', line 92 def client_id return @client_id end |
#client_secret ⇒ Object
96 97 98 |
# File 'lib/easycodefrb/easycodef.rb', line 96 def client_secret return @client_secret end |
#create_account(service_type, param) ⇒ Object
connectedID 발급을 위한 계정 등록
220 221 222 |
# 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) ⇒ Object
계정 정보 삭제
235 236 237 |
# 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 ⇒ Object
84 85 86 |
# File 'lib/easycodefrb/easycodef.rb', line 84 def demo_client_id return @demo_client_id end |
#demo_client_secret ⇒ Object
88 89 90 |
# File 'lib/easycodefrb/easycodef.rb', line 88 def demo_client_secret return @demo_client_secret end |
#get_account_list(service_type, param) ⇒ Object
connectedID로 등록된 계정 목록 조회
240 241 242 |
# 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) ⇒ Object
클라이언트 정보로 등록된 모든 connectedID 목록 조회
245 246 247 |
# 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) ⇒ Object
서비스 타입에 해당하는 요청 정보 객체 가져오기
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# 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) ⇒ Object
104 105 106 107 |
# 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) ⇒ Object
상품 추가인증 요청
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/easycodefrb/easycodef.rb', line 170 def request_certification(product_path, service_type, param) # 클라이언트 정보 검사 if !has_client_info(service_type) res = (Message::EMPTY_CLIENT_INFO) return res.to_json() end # 퍼블릭키 검사 if @public_key == '' res = (Message::EMPTY_PUBLIC_KEY) return res.to_json() end # 추가인증 파라미터 필수 입력 체크 if !has_require_two_way_info(param) res = (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) ⇒ Object
API 요청
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/easycodefrb/easycodef.rb', line 135 def request_product(product_path, service_type, param) # 클라이언트 정보 검사 if !has_client_info(service_type) res = (Message::EMPTY_CLIENT_INFO) return res.to_json() end # 퍼블릭키 검사 if @public_key == '' res = (Message::EMPTY_PUBLIC_KEY) return res.to_json() end # 추가인증 키워드 비어있는지 체크 if !is_empty_two_way_keyword(param) res = (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) ⇒ Object
토큰 요청
204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# 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) ⇒ Object
정식버전 클라이언트 정보 셋팅
73 74 75 76 |
# 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) ⇒ Object
데모버전 클라이언트 정보 셋팅
79 80 81 82 |
# 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) ⇒ Object
계정 정보 수정
230 231 232 |
# File 'lib/easycodefrb/easycodef.rb', line 230 def update_account(service_type, param) return request_product(PATH_UPDATE_ACCOUNT, service_type, param) end |