Class: SubscriptionBase

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

Direct Known Subclasses

Subscription

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_activate_subscription_response(response) ⇒ Object

method to handle activate subscription



62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/rave_ruby/rave_objects/base/subscription_base.rb', line 62

def handle_activate_subscription_response(response)
    handle_activate_subscription_response = response
    status = handle_activate_subscription_response["status"]
    message = handle_activate_subscription_response["message"]
    data = handle_activate_subscription_response["data"]

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

#handle_cancel_subscription_response(response) ⇒ Object

method to handle cancel subscription



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/rave_ruby/rave_objects/base/subscription_base.rb', line 45

def handle_cancel_subscription_response(response)
    cancel_subscription_response = response
    status = cancel_subscription_response["status"]
    message = cancel_subscription_response["message"]
    data = cancel_subscription_response["data"]

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

#handle_fetch_subscription_response(response) ⇒ Object

method to handle fetch subscription



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/rave_ruby/rave_objects/base/subscription_base.rb', line 27

def handle_fetch_subscription_response(response)
    fetch_subscription_response = response
    status = fetch_subscription_response["status"]
    message = fetch_subscription_response["message"]
    data = fetch_subscription_response["data"]

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

end

#handle_list_all_subscription(response) ⇒ Object

method to handle list subscription



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

def handle_list_all_subscription(response)

   list_all_subscription = response
   status = list_all_subscription["status"]
   message = list_all_subscription["message"]
  data = list_all_subscription["data"]
  plansubscriptions =list_all_subscription["data"]["plansubscriptions"]

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

end