/
config.rb
140 lines (124 loc) · 11.4 KB
/
config.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
require 'singleton'
require 'vindicia/util'
module Vindicia
API_CLASSES = {
"3.5" => {
:account=>[:update, :stop_auto_billing, :update_payment_method, :fetch_by_merchant_account_id, :fetch_by_vid, :fetch_by_web_session_vid, :fetch_by_email, :fetch_by_payment_method, :token_balance, :token_transaction, :increment_tokens, :decrement_tokens, :transfer, :redeem_gift_card, :grant_credit, :revoke_credit, :fetch_credit_history],
:activity=>[:record],
:address=>[:update, :fetch_by_vid],
:all_data_types=>[:get_vindicia],
:all_symc_data_types=>[:get_vindicia],
:auto_bill=>[:update, :cancel, :delay_billing_to_date, :delay_billing_by_days, :change_billing_day_of_month, :fetch_by_account_and_product, :fetch_by_merchant_auto_bill_id, :fetch_by_vid, :fetch_by_web_session_vid, :fetch_by_email, :fetch_by_account, :future_rebills, :fetch_delta_since, :redeem_gift_card, :grant_credit, :revoke_credit, :fetch_credit_history, :finalize_pay_pal_auth],
:billing_plan=>[:update, :fetch_by_vid, :fetch_by_merchant_billing_plan_id, :fetch_by_billing_plan_status, :fetch_all, :fetch_by_merchant_entitlement_id],
:chargeback=>[:update, :fetch_by_vid, :fetch_by_account, :fetch_by_case_number, :fetch_by_reference_number, :fetch_by_status, :fetch_by_status_since, :fetch_by_merchant_transaction_id, :fetch_delta_since, :fetch_delta, :report],
:diagnostic=>[:get_hello, :put_hello, :echo_string, :echo_string_by_proxy, :get_some_mock_transactions, :put_some_mock_transactions, :echo_boolean, :echo_date_time, :echo_mock_activity_fulfillment],
:electronic_signature=>[:sign, :get_signature_block],
:email_template=>[:update, :fetch_by_vid, :fetch_by_product, :fetch_by_type, :fetch_by_type_and_version],
:entitlement=>[:fetch_by_entitlement_id_and_account, :fetch_by_account, :fetch_delta_since],
:gift_card=>[:status_inquiry, :reverse],
:metric_statistics=>[:report],
:payment_method=>[:update, :fetch_by_vid, :fetch_by_web_session_vid, :fetch_by_account, :fetch_by_merchant_payment_method_id, :validate],
:payment_provider=>[:update, :fetch_by_vid],
:product=>[:update, :fetch_by_vid, :fetch_by_merchant_product_id, :fetch_by_account, :fetch_all, :fetch_by_merchant_entitlement_id],
:refund=>[:fetch_by_vid, :fetch_by_account, :fetch_by_transaction, :fetch_delta_since, :report, :perform],
:symantec=>[:add_auto_bill_item, :cancel_auto_bill, :cancel_pending_ar_txns, :delay_bill, :dispute_bill, :refund_ab_txns, :update_abs_account, :update_ab_product, :update_bp, :update_bp_and_catch_up_billing, :validate_bp, :fetch_b_ps_by_customer_guid, :lookup_transaction, :disable_billing_profile, :fetch_captured_transactions, :report_order_exception],
:token=>[:update, :fetch],
:transaction=>[:fetch_by_vid, :fetch_by_web_session_vid, :fetch_by_account, :fetch_by_merchant_transaction_id, :fetch_delta_since, :fetch_delta, :fetch_by_autobill, :fetch_search_page, :fetch_by_payment_method, :auth, :calculate_sales_tax, :capture, :cancel, :auth_capture, :report, :score, :finalize_pay_pal_auth],
:web_session=>[:initialize, :finalize, :fetch_by_vid]
},
"3.6" => {
:account=>[:update, :stop_auto_billing, :update_payment_method, :fetch_by_merchant_account_id, :fetch_by_vid, :fetch_by_web_session_vid, :fetch_by_email, :fetch_by_payment_method, :token_balance, :token_transaction, :increment_tokens, :decrement_tokens, :transfer, :redeem_gift_card, :grant_credit, :revoke_credit, :fetch_credit_history, :add_children, :remove_children, :fetch_family, :transfer_credit],
:activity=>[:record],
:address=>[:update, :fetch_by_vid],
:all_data_types=>[:get_vindicia],
:all_symc_data_types=>[:get_vindicia],
:auto_bill=>[:update, :upgrade, :fetch_upgrade_history_by_merchant_auto_bill_id, :fetch_upgrade_history_by_vid, :cancel, :delay_billing_to_date, :delay_billing_by_days, :change_billing_day_of_month, :fetch_by_account_and_product, :fetch_by_merchant_auto_bill_id, :fetch_by_vid, :fetch_by_web_session_vid, :fetch_by_email, :fetch_by_account, :future_rebills, :fetch_delta_since, :redeem_gift_card, :grant_credit, :revoke_credit, :fetch_credit_history, :finalize_pay_pal_auth],
:billing_plan=>[:update, :fetch_by_vid, :fetch_by_merchant_billing_plan_id, :fetch_by_billing_plan_status, :fetch_all, :fetch_by_merchant_entitlement_id],
:chargeback=>[:update, :fetch_by_vid, :fetch_by_account, :fetch_by_case_number, :fetch_by_reference_number, :fetch_by_status, :fetch_by_status_since, :fetch_by_merchant_transaction_id, :fetch_delta_since, :fetch_delta, :report],
:diagnostic=>[:get_hello, :put_hello, :echo_string, :echo_string_by_proxy, :get_some_mock_transactions, :put_some_mock_transactions, :echo_boolean, :echo_date_time, :echo_mock_activity_fulfillment, :useless_use_of_diagnostic_object],
:electronic_signature=>[:sign, :get_signature_block],
:email_template=>[:update, :fetch_by_vid, :fetch_by_product, :fetch_by_type, :fetch_by_type_and_version],
:entitlement=>[:fetch_by_entitlement_id_and_account, :fetch_by_account, :fetch_delta_since],
:gift_card=>[:status_inquiry, :reverse],
:metric_statistics=>[:report],
:payment_method=>[:update, :fetch_by_vid, :fetch_by_web_session_vid, :fetch_by_account, :fetch_by_merchant_payment_method_id, :validate],
:payment_provider=>[:update, :fetch_by_vid],
:product=>[:update, :fetch_by_vid, :fetch_by_merchant_product_id, :fetch_by_account, :fetch_all, :fetch_by_merchant_entitlement_id],
:refund=>[:fetch_by_vid, :fetch_by_account, :fetch_by_transaction, :fetch_delta_since, :report, :perform],
:symantec=>[:add_auto_bill_item, :cancel_auto_bill, :cancel_pending_ar_txns, :delay_bill, :dispute_bill, :refund_ab_txns, :update_abs_account, :update_ab_product, :update_bp, :update_bp_and_catch_up_billing, :validate_bp, :fetch_b_ps_by_customer_guid, :lookup_transaction, :disable_billing_profile, :fetch_captured_transactions, :report_order_exception],
:token=>[:update, :fetch],
:transaction=>[:fetch_by_vid, :fetch_by_web_session_vid, :fetch_by_account, :fetch_by_merchant_transaction_id, :fetch_delta_since, :fetch_delta, :fetch_by_autobill, :fetch_search_page, :fetch_by_payment_method, :auth, :calculate_sales_tax, :capture, :cancel, :auth_capture, :report, :score, :finalize_pay_pal_auth],
# :web_session=>[:initialize, :finalize, :fetch_by_vid] # initialize is a ruby reserved word. need to refactor to get this one to work =( @TQ
:web_session=>[:finalize, :fetch_by_vid]
},
"3.7" => {
:account => [:update, :stop_auto_billing, :update_payment_method, :fetch_by_merchant_account_id, :fetch_by_vid, :fetch_by_web_session_vid, :fetch_by_email, :fetch_by_payment_method, :token_balance, :token_transaction, :increment_tokens, :decrement_tokens, :transfer, :redeem_gift_card, :grant_credit, :revoke_credit, :fetch_credit_history, :add_children, :remove_children, :fetch_family, :transfer_credit, :make_payment, :reverse_payment, :is_entitled, :grant_entitlement, :revoke_entitlement, :extend_entitlement_to_date, :extend_entitlement_by_interval],
:activity => [:record],
:address => [:update, :fetch_by_vid],
:all_data_types => [:get_vindicia],
:all_symc_data_types => [:get_vindicia],
:auto_bill => [:update, :upgrade, :fetch_upgrade_history_by_merchant_auto_bill_id, :fetch_upgrade_history_by_vid, :cancel, :delay_billing_to_date, :delay_billing_by_days, :change_billing_day_of_month, :fetch_by_account_and_product, :fetch_by_merchant_auto_bill_id, :fetch_by_vid, :fetch_by_web_session_vid, :fetch_by_email, :fetch_by_account, :future_rebills, :fetch_delta_since, :redeem_gift_card, :grant_credit, :revoke_credit, :fetch_credit_history, :finalize_pay_pal_auth, :add_product, :remove_product, :add_charge, :make_payment, :reverse_payment, :fetch_invoice, :fetch_invoice_numbers, :write_off_invoice],
:billing_plan => [:update, :fetch_by_vid, :fetch_by_merchant_billing_plan_id, :fetch_by_billing_plan_status, :fetch_all, :fetch_by_merchant_entitlement_id],
:chargeback => [:update, :fetch_by_vid, :fetch_by_account, :fetch_by_case_number, :fetch_by_reference_number, :fetch_by_status, :fetch_by_status_since, :fetch_by_merchant_transaction_id, :fetch_delta_since, :fetch_delta, :report],
:diagnostic => [:get_hello, :put_hello, :echo_string, :echo_string_by_proxy, :get_some_mock_transactions, :put_some_mock_transactions, :echo_boolean, :echo_date_time, :echo_mock_activity_fulfillment, :useless_use_of_diagnostic_object],
:electronic_signature => [:sign, :get_signature_block],
:email_template => [:update, :fetch_by_vid, :fetch_by_product, :fetch_by_type, :fetch_by_type_and_version],
:entitlement => [:fetch_by_entitlement_id_and_account, :fetch_by_account, :fetch_delta_since],
:gift_card => [:status_inquiry, :reverse],
:metric_statistics => [:report],
:payment_method => [:update, :fetch_by_vid, :fetch_by_web_session_vid, :fetch_by_account, :fetch_by_merchant_payment_method_id, :validate],
:payment_provider => [:update, :fetch_by_vid],
:product => [:update, :fetch_by_vid, :fetch_by_merchant_product_id, :fetch_by_account, :fetch_all, :fetch_by_merchant_entitlement_id],
:refund => [:fetch_by_vid, :fetch_by_account, :fetch_by_transaction, :fetch_delta_since, :report, :perform],
:symantec => [:add_auto_bill_item, :cancel_auto_bill, :cancel_pending_ar_txns, :delay_bill, :dispute_bill, :refund_ab_txns, :update_abs_account, :update_ab_product, :update_bp, :update_bp_and_catch_up_billing, :validate_bp, :fetch_b_ps_by_customer_guid, :lookup_transaction, :disable_billing_profile, :fetch_captured_transactions, :report_order_exception],
:token => [:update, :fetch],
:transaction => [:fetch_by_vid, :fetch_by_web_session_vid, :fetch_by_account, :fetch_by_merchant_transaction_id, :fetch_delta_since, :fetch_delta, :fetch_by_autobill, :fetch_search_page, :fetch_by_payment_method, :auth, :calculate_sales_tax, :capture, :cancel, :auth_capture, :report, :score, :finalize_pay_pal_auth],
# :web_session=>[:initialize, :finalize, :fetch_by_vid] # initialize is a ruby reserved word. need to refactor to get this one to work =( @TQ
:web_session=> [:finalize, :fetch_by_vid]
}
}
class Configuration
include Singleton
attr_accessor :api_version, :login, :password, :endpoint, :namespace
def initialize
@@configured = false
end
def configured!
@@configured = true
end
def is_configured?
@@configured
end
end
def self.config
Configuration.instance
end
def self.configure
raise 'Vindicia-api gem has already been configured. Things might get hairy if we do this again with new values.' if config.is_configured?
yield config
if initialize!
config.configured!
end
end
private
def self.initialize!
return false unless API_CLASSES[config.api_version]
API_CLASSES[config.api_version].each_key do |vindicia_klass|
const_set(Vindicia::Util.camelize(vindicia_klass.to_s),
Class.new do
include Vindicia::Model
client do
http.headers["Pragma"] = "no-cache"
http.auth.ssl.verify_mode = :none # TODO set based on environment
end
api_version Vindicia.config.api_version
login Vindicia.config.login
password Vindicia.config.password
endpoint Vindicia.config.endpoint
namespace Vindicia.config.namespace
actions *API_CLASSES[Vindicia.config.api_version][vindicia_klass]
end
)
end
end
end