Class: PaymentPlanBase

Inherits:
Base
  • Object
show all
Defined in:
lib/rave_ruby/rave_objects/base/payment_plan_base.rb

Direct Known Subclasses

PaymentPlan

Instance Attribute Summary

Attributes inherited from Base

#get_hashed_key, #rave_object

Instance Method Summary collapse

Methods inherited from Base

#check_passed_parameters, #get_request, #handle_list_bank, #initialize, #post_request

Constructor Details

This class inherits a constructor from Base

Instance Method Details

#handle_cancel_response(response) ⇒ Object

method to handle cancel payment response



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/rave_ruby/rave_objects/base/payment_plan_base.rb', line 57

def handle_cancel_response(response)
    cancel_response = response
    status = cancel_response["status"]
    data = cancel_response["data"]

    if status == "success"
        response = {"error": false, "data": data}
        return JSON.parse(response.to_json)
    else
        response = {"error": true, "data": data}
        raise CancelPaymentPlanError, JSON.parse(response.to_json)
    end
end

#handle_create_response(response) ⇒ Object

method to handle payment plan response



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rave_ruby/rave_objects/base/payment_plan_base.rb', line 7

def handle_create_response(response)

    create_response = response
    statusMessage = create_response["status"]

    if statusMessage == "success"
        response = {"error": false, "data": create_response["data"]}
        return JSON.parse(response.to_json)
    else
        response = {"error": true, "data": create_response["data"]}
        raise CreatePaymentPlanError, JSON.parse(response.to_json)
    end
end

#handle_edit_response(response) ⇒ Object

method to handle edit payment plan response



72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/rave_ruby/rave_objects/base/payment_plan_base.rb', line 72

def handle_edit_response(response)
    edit_response = response
    status = edit_response["status"]
    data = edit_response["data"]

    if status == "success"
        response = {"error": false, "data": data}
        return JSON.parse(response.to_json)
    else
        response = {"error": true, "data": data}
        raise EditPaymentPlanError, JSON.parse(response.to_json)
    end
end

#handle_fetch_response(response) ⇒ Object

method to handle fetch payment plan response



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rave_ruby/rave_objects/base/payment_plan_base.rb', line 41

def handle_fetch_response(response)
    fetch_response = response
    status = fetch_response["status"]
    data = fetch_response["data"]

    if status == "success"
        response = {"error": false, "data": data}
        return JSON.parse(response.to_json)
    else
        response = {"error": true, "data": data}
        raise FetchPaymentPlanError, JSON.parse(response.to_json)
    end

end

#handle_list_response(response) ⇒ Object

method to list payment plan



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rave_ruby/rave_objects/base/payment_plan_base.rb', line 23

def handle_list_response(response)
    list_response = response

    status = list_response["status"]
    message = list_response["message"]
   data = list_response["data"]
   paymentplans = list_response["data"]["paymentplans"]

    if status == "success"
        response = {"error": false, "status": status,"message": message, "data": data}
        return JSON.parse(response.to_json)
    else
        response = {"error": true, "data": list_response["data"]}
        raise ListPaymentPlanError, JSON.parse(response.to_json)
    end
end