Class: Chockstone::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/chockstone/connection.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Connection

Returns a new instance of Connection.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/chockstone/connection.rb', line 4

def initialize *args
  
  return unless args[0].is_a?(Hash)

  options = args[0]
  @url = options[:url]

  uri = URI(@url)
  @host   = uri.host
  @port   = uri.port
  @scheme = uri.scheme
  @path   = uri.path

  @domain         = options[:domain]
  @profile        = options[:profile]
  @seller_profile = options[:seller_profile]
  @password       = options[:password]

  connection

end

Instance Method Details

#add_user_bank_card(id, card = {}) ⇒ Object



91
92
93
94
95
96
97
98
# File 'lib/chockstone/connection.rb', line 91

def add_user_bank_card id, card={}
  request('add-user-bank-card',
    :user => {
      :id => id
    },
    :bank_card => card
  )
end

#auth_user(id, password) ⇒ Object Also known as: authenticate_user

api requests



27
28
29
30
31
32
33
34
35
36
# File 'lib/chockstone/connection.rb', line 27

def auth_user id, password

  request('authenticate-user', 
    :user => { 
      :id => id,
      :password => password
    }
  )

end

#create_user(user = {}, account = {}) ⇒ Object

account argument hash will invoke an account creation



50
51
52
53
54
55
56
57
58
# File 'lib/chockstone/connection.rb', line 50

def create_user user={}, ={}

  req = {}
  req.merge!({ :user => user }) unless user.empty?
  req.merge!({ :account =>  }) unless .empty?

  request('create-user', req)

end

#delete_user_bank_card(id, card_id) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
# File 'lib/chockstone/connection.rb', line 100

def delete_user_bank_card id, card_id
  request('delete-user-bank-card',
    :user => {
      :id => id
    },
    :bank_card => {
      :id => card_id
    }
  )

end

#get_account_balance(authorization = {}) ⇒ Object

need to pass the authorization request block as a hash ex. “pin authorization”: {

:pin_authorization => {
  :id => '6277111111111111',
  :pin => '1234'
}

}

ex. “credit-card-authorization”: {

:credit_card_authorization => {
  :number => '',
  :expiration_date => {
    :month => '',
    :year => ''
  },
  :cvv2 => ''
}

}

ex. “phone-number-authorization”: {

:phone_number_authorization => {
  :number => '',
  :pin => ''
}

}



140
141
142
143
144
# File 'lib/chockstone/connection.rb', line 140

def  authorization={}
  request('get-account-balance', 
    :account => authorization
  )
end

#get_user(id) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/chockstone/connection.rb', line 39

def get_user id

  request('get-user', 
    :user => { 
      :id => id 
    }
  )

end

#transfer_account(from, to) ⇒ Object



197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/chockstone/connection.rb', line 197

def  from, to
  request('transfer-account',
    :from => {
      :account => {
        :id => from
      }
    },
    :to => {
      :account => {
        :id => to
      }
    }
  ) 
end

#update_account_alias(account_id, authorization = {}) ⇒ Object

need to pass the authorization request block as a hash ex. “credit-card-authorization”: {

:credit_card_authorization => {
  :number => '',
  :expiration_date => {
    :month => '',
    :year => ''
  },
  :cvv2 => ''
}

}

ex. “phone-number-authorization”: {

:phone_number_authorization => {
  :number => '',
  :pin => ''
}

}



166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/chockstone/connection.rb', line 166

def  , authorization={}

  req = {
    :id => 
  }

  req.merge!(authorization)

  request('update-account-alias', 
    :account => req
  )
end

#update_user(user = {}) ⇒ Object



60
61
62
63
64
# File 'lib/chockstone/connection.rb', line 60

def update_user user={}
  request('update-user', 
    :user => user
  )
end

#update_user_id(id, new_id) ⇒ Object

update user ‘id’ (email)



67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/chockstone/connection.rb', line 67

def update_user_id id, new_id
  request('update-user-id', 
    :old => {
      :user => {
        :id => id
      }
    },
    :new => {
      :user => {
        :id => new_id
      }
    }
  )
end

#update_user_password(id, password) ⇒ Object



82
83
84
85
86
87
88
89
# File 'lib/chockstone/connection.rb', line 82

def update_user_password id, password
  request('update-user-password',
    :user => {
      :id => id,
      :password => password
    }
  )
end

#view_account_activity(account_id, page = {}) ⇒ Object

page argument needs to be a hash with the page at a bare minimum your page argument hash needs to include:

:number => 1,
:transactions_per_page => 50,
:sort_by_date => 'descending' #(descending|ascending)



187
188
189
190
191
192
193
194
195
# File 'lib/chockstone/connection.rb', line 187

def  , page={}

  request('view-account-activity',  
    :account => {
      :id => 
    },
    :page => page
  )
end