cashstar 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cashstar/entities.rb +12 -1
- data/lib/cashstar/entities/base.rb +10 -2
- data/lib/cashstar/entities/catalog.rb +3 -11
- data/lib/cashstar/entities/credit_card.rb +10 -0
- data/lib/cashstar/entities/faceplate.rb +5 -6
- data/lib/cashstar/entities/gift_certificate.rb +21 -0
- data/lib/cashstar/entities/gift_certificate_delivery.rb +13 -0
- data/lib/cashstar/entities/gift_certificate_message.rb +11 -0
- data/lib/cashstar/entities/merchant.rb +14 -9
- data/lib/cashstar/entities/order.rb +39 -0
- data/lib/cashstar/entities/payment.rb +10 -0
- data/lib/cashstar/entities/purchaser.rb +10 -0
- data/lib/cashstar/entities/purchaser_account.rb +10 -0
- data/lib/cashstar/entities/web_session.rb +10 -0
- data/lib/cashstar/version.rb +1 -1
- metadata +11 -5
- data/lib/cashstar/entities/gift_card.rb +0 -0
data/lib/cashstar/entities.rb
CHANGED
@@ -5,5 +5,16 @@ module Cashstar
|
|
5
5
|
end
|
6
6
|
|
7
7
|
require 'cashstar/entities/base'
|
8
|
+
require 'cashstar/entities/catalog'
|
9
|
+
require 'cashstar/entities/credit_card'
|
10
|
+
require 'cashstar/entities/error'
|
11
|
+
require 'cashstar/entities/faceplate'
|
12
|
+
require 'cashstar/entities/gift_certificate'
|
13
|
+
require 'cashstar/entities/gift_certificate_delivery'
|
14
|
+
require 'cashstar/entities/gift_certificate_message'
|
8
15
|
require 'cashstar/entities/merchant'
|
9
|
-
require 'cashstar/entities/
|
16
|
+
require 'cashstar/entities/order'
|
17
|
+
require 'cashstar/entities/payment'
|
18
|
+
require 'cashstar/entities/purchaser'
|
19
|
+
require 'cashstar/entities/purchaser_account'
|
20
|
+
require 'cashstar/entities/web_session'
|
@@ -2,9 +2,17 @@ module Cashstar
|
|
2
2
|
module Entities
|
3
3
|
|
4
4
|
class Base
|
5
|
-
cattr_accessor :
|
6
|
-
self.
|
5
|
+
cattr_accessor :remote_url, :headers
|
6
|
+
self.remote_url = "https://petes_dad:Eghrt3gad3@api-semiprod.cashstar.com/v2"
|
7
7
|
self.headers = {:accept => "application/json", :content_type => "application/json"}
|
8
|
+
|
9
|
+
def initialize args
|
10
|
+
args.each do |k,v|
|
11
|
+
#raise "#{k} Does Not Exist" if not instance_variable_defined? "@#{k}"
|
12
|
+
instance_variable_set("@#{k}", v) unless v.nil?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
8
16
|
|
9
17
|
end
|
10
18
|
end
|
@@ -1,19 +1,11 @@
|
|
1
1
|
require 'json'
|
2
2
|
module Cashstar
|
3
3
|
module Entities
|
4
|
-
|
5
|
-
|
6
|
-
self.site = "https://petes_dad:Eghrt3gad3@api-semiprod.cashstar.com/v2/merchant/"
|
7
|
-
self.headers = {:accept => "application/json", :content_type => "application/json"}
|
8
|
-
|
9
|
-
attr_accessor :site
|
10
|
-
|
11
|
-
def initialize(merchant_code)
|
12
|
-
@site = "https://petes_dad:Eghrt3gad3@api-semiprod.cashstar.com/v2/merchant/#{merchant_code}/catalog"
|
13
|
-
end
|
4
|
+
class Catalog < Base
|
5
|
+
|
14
6
|
|
15
7
|
def self.all()
|
16
|
-
json = JSON.parse RestClient.get
|
8
|
+
json = JSON.parse RestClient.get remote_url, headers
|
17
9
|
merchants = []
|
18
10
|
json["merchants"]["merchant"].each do |merchant|
|
19
11
|
merchants << Merchant.new(merchant["merchant_code"],merchant["name"])
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'json'
|
2
|
+
module Cashstar
|
3
|
+
module Entities
|
4
|
+
|
5
|
+
class CreditCard < Base
|
6
|
+
attr_accessor :card_type, :account_number, :security_code, :expiration_date, :first_name, :last_name, :address, :address2, :city, :state_code, :postal_code, :country_code, :phone, :email
|
7
|
+
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -7,16 +7,15 @@ module Cashstar
|
|
7
7
|
|
8
8
|
attr_accessor :faceplate_code, :name, :text_color, :thumbnail, :preview, :print
|
9
9
|
|
10
|
-
|
11
|
-
@faceplate_code, @name, @text_color, @thumbnail, @preview, @print = faceplate_code, name, text_color, thumbnail, preview, print
|
12
|
-
end
|
10
|
+
|
13
11
|
|
14
12
|
def self.all(merchant_code)
|
15
|
-
|
13
|
+
remote_url = self.remote_url + "/merchant/#{merchant_code}/faceplate/"
|
14
|
+
json = JSON.parse RestClient.get remote_url, headers
|
16
15
|
faceplates = []
|
17
16
|
json["faceplates"]["faceplate"].each do |faceplate|
|
18
|
-
faceplates << Faceplate.new(faceplate["faceplate_code"]
|
19
|
-
faceplate["thumbnail"], faceplate["preview"], faceplate["print"])
|
17
|
+
faceplates << Faceplate.new(:faceplate_code => faceplate["faceplate_code"],:name => faceplate["name"],:text_color => faceplate["text_color"],
|
18
|
+
:thumbnail => faceplate["thumbnail"], :preview => faceplate["preview"], :print => faceplate["print"])
|
20
19
|
end
|
21
20
|
return faceplates
|
22
21
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'json'
|
2
|
+
module Cashstar
|
3
|
+
module Entities
|
4
|
+
|
5
|
+
class GiftCertificate < Base
|
6
|
+
|
7
|
+
attr_accessor :egc_code, :egc_number, :access_code, :merchant_code, :initial_balance, :current_balance, :balance_last_updated
|
8
|
+
attr_accessor :balance_url, :currency, :active, :status, :url, :challenge, :challenge_description, :challenge_type, :faceplate_code
|
9
|
+
attr_accessor :audit_number, :delivery, :message
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
@@ -5,23 +5,28 @@ module Cashstar
|
|
5
5
|
class Merchant < Base
|
6
6
|
attr_accessor :merchant_code, :name, :logo, :faceplates
|
7
7
|
|
8
|
-
def initialize(merchant_code, name)
|
9
|
-
@merchant_code, @name = merchant_code, name
|
10
|
-
end
|
11
8
|
|
12
9
|
def faceplates
|
13
10
|
@faceplates ||= Faceplate.all(@merchant_code)
|
14
11
|
end
|
15
12
|
|
16
13
|
def self.all()
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
remote_url = self.remote_url + "/merchant/"
|
15
|
+
result = RestClient.get remote_url , headers
|
16
|
+
print result
|
17
|
+
if result.code == "200"
|
18
|
+
json = JSON.parse result
|
19
|
+
merchants = []
|
20
|
+
json["merchants"]["merchant"].each do |merchant|
|
21
|
+
merchants << Merchant.new(:merchant_code => merchant["merchant_code"], :name => merchant["name"])
|
22
|
+
end
|
23
|
+
return merchants
|
24
|
+
else
|
25
|
+
return result
|
21
26
|
end
|
22
|
-
return merchants
|
23
27
|
end
|
24
28
|
|
25
29
|
end
|
26
30
|
end
|
27
|
-
end
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'json'
|
2
|
+
module Cashstar
|
3
|
+
module Entities
|
4
|
+
|
5
|
+
class Order < Base
|
6
|
+
|
7
|
+
attr_accessor :order_number, :transaction_id, :audit_number, :activation_callback_url, :egc, :payment, :response
|
8
|
+
|
9
|
+
def post_json
|
10
|
+
"{ \"order\" : #{self.to_json}}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def purchase
|
14
|
+
remote_url = self.remote_url + "/order/"
|
15
|
+
begin
|
16
|
+
result = RestClient.post remote_url, self.post_json, headers
|
17
|
+
self.response = result
|
18
|
+
print result.code
|
19
|
+
if result.code == 201
|
20
|
+
json = JSON.parse result
|
21
|
+
self.order_number = json["order"]["order_number"]
|
22
|
+
self.transaction_id = json["order"]["transaction_id"]
|
23
|
+
self.audit_number = json["order"]["audit_number"]
|
24
|
+
self.egc.url = json["order"]["egc"]["url"]
|
25
|
+
self.egc.status = json["order"]["egc"]["status"]
|
26
|
+
self.egc.initial_balance = json["order"]["egc"]["initial_balance"]
|
27
|
+
return true
|
28
|
+
else
|
29
|
+
return false
|
30
|
+
end
|
31
|
+
rescue => e
|
32
|
+
self.response = e.response
|
33
|
+
return false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/cashstar/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cashstar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Charlie White
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-11 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -52,12 +52,18 @@ files:
|
|
52
52
|
- lib/cashstar/entities.rb
|
53
53
|
- lib/cashstar/entities/base.rb
|
54
54
|
- lib/cashstar/entities/catalog.rb
|
55
|
+
- lib/cashstar/entities/credit_card.rb
|
55
56
|
- lib/cashstar/entities/error.rb
|
56
57
|
- lib/cashstar/entities/faceplate.rb
|
57
|
-
- lib/cashstar/entities/
|
58
|
+
- lib/cashstar/entities/gift_certificate.rb
|
59
|
+
- lib/cashstar/entities/gift_certificate_delivery.rb
|
60
|
+
- lib/cashstar/entities/gift_certificate_message.rb
|
58
61
|
- lib/cashstar/entities/merchant.rb
|
59
62
|
- lib/cashstar/entities/order.rb
|
60
63
|
- lib/cashstar/entities/payment.rb
|
64
|
+
- lib/cashstar/entities/purchaser.rb
|
65
|
+
- lib/cashstar/entities/purchaser_account.rb
|
66
|
+
- lib/cashstar/entities/web_session.rb
|
61
67
|
- lib/cashstar/version.rb
|
62
68
|
has_rdoc: true
|
63
69
|
homepage: http://www.cashstar.com
|
File without changes
|