Class: Bootpay::Commerce::Api
- Inherits:
-
CommerceResource
- Object
- CommerceResource
- Bootpay::Commerce::Api
- Defined in:
- lib/bootpay_commerce.rb
Overview
Bootpay Commerce API 클라이언트
사용 예시:
commerce = Bootpay::Commerce::Api.new(
client_key: 'your_client_key',
secret_key: 'your_secret_key',
mode: 'production'
)
# 액세스 토큰 발급
token_response = commerce.get_access_token
# Role 설정 (메서드 체이닝 지원)
commerce.as_manager
# 사용자 목록 조회
users = commerce.user.list(page: 1, limit: 10)
# 상품 생성 (이미지 포함)
product = commerce.product.create({ name: '상품명', price: 10000 }, ['/path/to/image.jpg'])
Constant Summary
Constants inherited from CommerceResource
CommerceResource::API_ENTRYPOINTS, CommerceResource::API_VERSION, CommerceResource::SDK_TYPE, CommerceResource::SDK_VERSION
Instance Attribute Summary collapse
-
#cart ⇒ Object
readonly
Returns the value of attribute cart.
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#coupon ⇒ Object
readonly
Returns the value of attribute coupon.
-
#invoice ⇒ Object
readonly
Returns the value of attribute invoice.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#order_cancel ⇒ Object
readonly
Returns the value of attribute order_cancel.
-
#order_subscription ⇒ Object
readonly
Returns the value of attribute order_subscription.
-
#order_subscription_adjustment ⇒ Object
readonly
Returns the value of attribute order_subscription_adjustment.
-
#order_subscription_bill ⇒ Object
readonly
Returns the value of attribute order_subscription_bill.
-
#order_subscription_request ⇒ Object
readonly
Returns the value of attribute order_subscription_request.
-
#point ⇒ Object
readonly
Returns the value of attribute point.
-
#product ⇒ Object
readonly
Returns the value of attribute product.
-
#store ⇒ Object
readonly
Returns the value of attribute store.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#user_group ⇒ Object
readonly
Returns the value of attribute user_group.
Attributes inherited from CommerceResource
#client_key, #mode, #secret_key
Instance Method Summary collapse
-
#as_manager ⇒ Object
매니저 role로 설정.
-
#as_partner ⇒ Object
파트너 role로 설정.
-
#as_supervisor ⇒ Object
슈퍼바이저 role로 설정.
-
#as_user ⇒ Object
일반 사용자 role로 설정.
-
#as_vendor ⇒ Object
벤더 role로 설정.
-
#clear_role ⇒ Object
role을 기본값(user)으로 초기화.
-
#current_role ⇒ Object
현재 role 반환.
-
#current_token ⇒ Object
현재 설정된 토큰 반환.
-
#get_access_token ⇒ Object
액세스 토큰 발급 client_key/secret_key로 Basic Auth 인증.
-
#has_token? ⇒ Boolean
토큰이 설정되어 있는지 확인.
-
#initialize(client_key: nil, secret_key: nil, mode: 'production') ⇒ Api
constructor
A new instance of Api.
-
#with_role(role) ⇒ Object
Role 설정 (메서드 체이닝).
-
#with_token ⇒ Object
토큰을 발급받아 설정 (메서드 체이닝).
Methods inherited from CommerceResource
#delete, #get, #get_role, #get_token, #post, #post_multipart, #post_with_basic_auth, #put, #set_configuration, #set_role, #set_token
Constructor Details
#initialize(client_key: nil, secret_key: nil, mode: 'production') ⇒ Api
Returns a new instance of Api.
49 50 51 52 53 54 55 |
# File 'lib/bootpay_commerce.rb', line 49 def initialize(client_key: nil, secret_key: nil, mode: 'production') super() if client_key && secret_key set_configuration(client_key: client_key, secret_key: secret_key, mode: mode) end init_modules end |
Instance Attribute Details
#cart ⇒ Object (readonly)
Returns the value of attribute cart.
44 45 46 |
# File 'lib/bootpay_commerce.rb', line 44 def cart @cart end |
#category ⇒ Object (readonly)
Returns the value of attribute category.
44 45 46 |
# File 'lib/bootpay_commerce.rb', line 44 def category @category end |
#coupon ⇒ Object (readonly)
Returns the value of attribute coupon.
44 45 46 |
# File 'lib/bootpay_commerce.rb', line 44 def coupon @coupon end |
#invoice ⇒ Object (readonly)
Returns the value of attribute invoice.
44 45 46 |
# File 'lib/bootpay_commerce.rb', line 44 def invoice @invoice end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
44 45 46 |
# File 'lib/bootpay_commerce.rb', line 44 def order @order end |
#order_cancel ⇒ Object (readonly)
Returns the value of attribute order_cancel.
44 45 46 |
# File 'lib/bootpay_commerce.rb', line 44 def order_cancel @order_cancel end |
#order_subscription ⇒ Object (readonly)
Returns the value of attribute order_subscription.
44 45 46 |
# File 'lib/bootpay_commerce.rb', line 44 def order_subscription @order_subscription end |
#order_subscription_adjustment ⇒ Object (readonly)
Returns the value of attribute order_subscription_adjustment.
44 45 46 |
# File 'lib/bootpay_commerce.rb', line 44 def order_subscription_adjustment @order_subscription_adjustment end |
#order_subscription_bill ⇒ Object (readonly)
Returns the value of attribute order_subscription_bill.
44 45 46 |
# File 'lib/bootpay_commerce.rb', line 44 def order_subscription_bill @order_subscription_bill end |
#order_subscription_request ⇒ Object (readonly)
Returns the value of attribute order_subscription_request.
44 45 46 |
# File 'lib/bootpay_commerce.rb', line 44 def order_subscription_request @order_subscription_request end |
#point ⇒ Object (readonly)
Returns the value of attribute point.
44 45 46 |
# File 'lib/bootpay_commerce.rb', line 44 def point @point end |
#product ⇒ Object (readonly)
Returns the value of attribute product.
44 45 46 |
# File 'lib/bootpay_commerce.rb', line 44 def product @product end |
#store ⇒ Object (readonly)
Returns the value of attribute store.
44 45 46 |
# File 'lib/bootpay_commerce.rb', line 44 def store @store end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
44 45 46 |
# File 'lib/bootpay_commerce.rb', line 44 def user @user end |
#user_group ⇒ Object (readonly)
Returns the value of attribute user_group.
44 45 46 |
# File 'lib/bootpay_commerce.rb', line 44 def user_group @user_group end |
Instance Method Details
#as_manager ⇒ Object
매니저 role로 설정
101 102 103 |
# File 'lib/bootpay_commerce.rb', line 101 def as_manager with_role('manager') end |
#as_partner ⇒ Object
파트너 role로 설정
106 107 108 |
# File 'lib/bootpay_commerce.rb', line 106 def as_partner with_role('partner') end |
#as_supervisor ⇒ Object
슈퍼바이저 role로 설정
116 117 118 |
# File 'lib/bootpay_commerce.rb', line 116 def as_supervisor with_role('supervisor') end |
#as_user ⇒ Object
일반 사용자 role로 설정
96 97 98 |
# File 'lib/bootpay_commerce.rb', line 96 def as_user with_role('user') end |
#as_vendor ⇒ Object
벤더 role로 설정
111 112 113 |
# File 'lib/bootpay_commerce.rb', line 111 def as_vendor with_role('vendor') end |
#clear_role ⇒ Object
role을 기본값(user)으로 초기화
126 127 128 129 |
# File 'lib/bootpay_commerce.rb', line 126 def clear_role set_role('user') self end |
#current_role ⇒ Object
현재 role 반환
121 122 123 |
# File 'lib/bootpay_commerce.rb', line 121 def current_role get_role end |
#current_token ⇒ Object
현재 설정된 토큰 반환
79 80 81 |
# File 'lib/bootpay_commerce.rb', line 79 def current_token get_token end |
#get_access_token ⇒ Object
액세스 토큰 발급client_key/secret_key로 Basic Auth 인증
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/bootpay_commerce.rb', line 59 def get_access_token response = post_with_basic_auth('request/token', { client_key: @client_key, secret_key: @secret_key }) if response.is_a?(Hash) && response[:access_token] set_token(response[:access_token]) end response end |
#has_token? ⇒ Boolean
토큰이 설정되어 있는지 확인
84 85 86 87 |
# File 'lib/bootpay_commerce.rb', line 84 def has_token? token = get_token !token.nil? && !token.empty? end |
#with_role(role) ⇒ Object
Role 설정 (메서드 체이닝)
90 91 92 93 |
# File 'lib/bootpay_commerce.rb', line 90 def with_role(role) set_role(role) self end |
#with_token ⇒ Object
토큰을 발급받아 설정 (메서드 체이닝)
73 74 75 76 |
# File 'lib/bootpay_commerce.rb', line 73 def with_token get_access_token self end |