Class: Xdelivery::Callback
- Inherits:
-
Object
- Object
- Xdelivery::Callback
- Defined in:
- lib/xdelivery/callback.rb
Constant Summary collapse
- PARAM_KEYS =
[ :action, :title, :desc, :provider, :created_at ]
Instance Attribute Summary collapse
-
#access_key ⇒ Object
Returns the value of attribute access_key.
-
#check_code ⇒ Object
Returns the value of attribute check_code.
-
#merchant_no ⇒ Object
Returns the value of attribute merchant_no.
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
- #action ⇒ Object
- #created_at ⇒ Object
- #desc ⇒ Object
-
#initialize(merchant_no, access_key, params) ⇒ Callback
constructor
A new instance of Callback.
- #provider ⇒ Object
- #title ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(merchant_no, access_key, params) ⇒ Callback
Returns a new instance of Callback.
7 8 9 10 11 12 13 14 15 |
# File 'lib/xdelivery/callback.rb', line 7 def initialize(merchant_no, access_key, params) self.params = PARAM_KEYS.map do |key| [ key, params[key] ] end.to_h self.check_code = params[:check_code] self.merchant_no = merchant_no self.access_key = access_key end |
Instance Attribute Details
#access_key ⇒ Object
Returns the value of attribute access_key.
3 4 5 |
# File 'lib/xdelivery/callback.rb', line 3 def access_key @access_key end |
#check_code ⇒ Object
Returns the value of attribute check_code.
3 4 5 |
# File 'lib/xdelivery/callback.rb', line 3 def check_code @check_code end |
#merchant_no ⇒ Object
Returns the value of attribute merchant_no.
3 4 5 |
# File 'lib/xdelivery/callback.rb', line 3 def merchant_no @merchant_no end |
#params ⇒ Object
Returns the value of attribute params.
3 4 5 |
# File 'lib/xdelivery/callback.rb', line 3 def params @params end |
Instance Method Details
#action ⇒ Object
21 22 23 |
# File 'lib/xdelivery/callback.rb', line 21 def action params[:action] end |
#created_at ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/xdelivery/callback.rb', line 37 def created_at if params[:created_at] == '' nil elsif Time.respond_to?(:zone) Time.zone.parse(params[:created_at]) else Time.parse(params[:created_at]) end end |
#desc ⇒ Object
29 30 31 |
# File 'lib/xdelivery/callback.rb', line 29 def desc params[:desc] end |
#provider ⇒ Object
33 34 35 |
# File 'lib/xdelivery/callback.rb', line 33 def provider params[:provider] end |
#title ⇒ Object
25 26 27 |
# File 'lib/xdelivery/callback.rb', line 25 def title params[:title] end |
#valid? ⇒ Boolean
17 18 19 |
# File 'lib/xdelivery/callback.rb', line 17 def valid? check_code == check_code! end |