Module: Culqi::Get

Included in:
Card, Charge, Customer, Event, Iins, Order, Plan, Refund, Subscription, Token, Transfer
Defined in:
lib/operation/get.rb

Instance Method Summary collapse

Instance Method Details

#get(id) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/operation/get.rb', line 10

def get(id)
  error = verifyClassValidationGet(@url, id)
  if error
    return error
  end
  response = Culqi.connect("#{@url}#{id}/", Culqi.secret_key, nil, 'get', Culqi::READ_TIMEOUT)
  return response
end

#initializeObject



6
7
8
# File 'lib/operation/get.rb', line 6

def initialize
  @url = ''
end

#verifyClassValidationGet(url = '', id) ⇒ Object



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
# File 'lib/operation/get.rb', line 19

def verifyClassValidationGet(url='', id)
  begin
    if @url.include? 'token'
      HelperValidation.validate_string_start(id, "tkn")
    end

    if @url.include? 'charge'
      HelperValidation.validate_string_start(id, "chr")
    end
    
    if @url.include? 'card'
      HelperValidation.validate_string_start(id, "crd")
    end
    
    if @url.include? 'customer'
      HelperValidation.validate_string_start(id, "cus")
    end
    
    if @url.include? 'refund'
      HelperValidation.validate_string_start(id, "ref")
    end
    
    if @url.include? 'plan'
      HelperValidation.validate_string_start(id, "pln")
    end
    
    if @url.include? 'subscription'
      HelperValidation.validate_string_start(id, "sxn")
    end
    
    if @url.include? 'order'
      HelperValidation.validate_string_start(id, "ord")
    end
  rescue CustomException => e
    return e.message
  end
end