cashstar 0.0.2

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/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in cashstar.gemspec
4
+ gemspec
5
+ gem "activesupport"
6
+ gem "json"
7
+ gem "rest-client"
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/cashstar.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "cashstar/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "cashstar"
7
+ s.version = Cashstar::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Charlie White"]
10
+ s.email = ["cwhite@cashstar.com"]
11
+ s.homepage = "http://www.cashstar.com"
12
+ s.summary = %q{Ruby Bindings for the CashStar API}
13
+ s.description = %q{CashStar's API provides a simple interface for purchasing and issuing electronic gift cards from a variety of brands}
14
+
15
+ s.add_dependency('rest-client', ">=1.6.1")
16
+ s.rubyforge_project = "cashstar"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+ #s.files = Dir['lib/**/*.rb']
23
+ end
data/lib/cashstar.rb ADDED
@@ -0,0 +1,25 @@
1
+
2
+
3
+
4
+ require 'active_support'
5
+ require 'active_support/core_ext/string/inflections'
6
+ require 'active_support/core_ext/hash/indifferent_access'
7
+ require 'active_support/core_ext/hash/conversions'
8
+ require 'active_support/core_ext/class/inheritable_attributes'
9
+ require 'active_support/core_ext/class/attribute_accessors'
10
+ require 'active_support/core_ext/class/delegating_attributes'
11
+ require 'active_support/core_ext/module/attribute_accessors'
12
+ require 'active_support/core_ext/kernel/requires'
13
+ require 'active_support/base64'
14
+ require 'active_support/secure_random'
15
+ require 'rest_client'
16
+
17
+
18
+
19
+ module Cashstar
20
+ # Your code goes here...
21
+ RestClient.log = 'restclient.log'
22
+ end
23
+
24
+
25
+ require "cashstar/entities"
@@ -0,0 +1,9 @@
1
+ module Cashstar
2
+ module Entities
3
+
4
+ end
5
+ end
6
+
7
+ require 'cashstar/entities/base'
8
+ require 'cashstar/entities/merchant'
9
+ require 'cashstar/entities/faceplate'
@@ -0,0 +1,11 @@
1
+ module Cashstar
2
+ module Entities
3
+
4
+ class Base
5
+ cattr_accessor :site, :headers
6
+ self.site = "https://petes_dad:Eghrt3gad3@api-semiprod.cashstar.com/v2"
7
+ self.headers = {:accept => "application/json", :content_type => "application/json"}
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,26 @@
1
+ require 'json'
2
+ module Cashstar
3
+ module Entities
4
+ module Catalog
5
+ cattr_accessor :site, :headers
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
14
+
15
+ def self.all()
16
+ json = JSON.parse RestClient.get site, headers
17
+ merchants = []
18
+ json["merchants"]["merchant"].each do |merchant|
19
+ merchants << Merchant.new(merchant["merchant_code"],merchant["name"])
20
+ end
21
+ return merchants
22
+ end
23
+
24
+ end
25
+ end
26
+ end
File without changes
@@ -0,0 +1,26 @@
1
+ require 'json'
2
+
3
+ module Cashstar
4
+ module Entities
5
+
6
+ class Faceplate < Base
7
+
8
+ attr_accessor :faceplate_code, :name, :text_color, :thumbnail, :preview, :print
9
+
10
+ def initialize(faceplate_code, name, text_color, thumbnail, preview, print)
11
+ @faceplate_code, @name, @text_color, @thumbnail, @preview, @print = faceplate_code, name, text_color, thumbnail, preview, print
12
+ end
13
+
14
+ def self.all(merchant_code)
15
+ json = JSON.parse RestClient.get site + "/merchant/#{merchant_code}/faceplate", headers
16
+ faceplates = []
17
+ json["faceplates"]["faceplate"].each do |faceplate|
18
+ faceplates << Faceplate.new(faceplate["faceplate_code"],faceplate["name"], faceplate["text_color"],
19
+ faceplate["thumbnail"], faceplate["preview"], faceplate["print"])
20
+ end
21
+ return faceplates
22
+ end
23
+
24
+ end
25
+ end
26
+ end
File without changes
@@ -0,0 +1,27 @@
1
+ require 'json'
2
+ module Cashstar
3
+ module Entities
4
+
5
+ class Merchant < Base
6
+ attr_accessor :merchant_code, :name, :logo, :faceplates
7
+
8
+ def initialize(merchant_code, name)
9
+ @merchant_code, @name = merchant_code, name
10
+ end
11
+
12
+ def faceplates
13
+ @faceplates ||= Faceplate.all(@merchant_code)
14
+ end
15
+
16
+ def self.all()
17
+ json = JSON.parse RestClient.get site + "/merchant" , headers
18
+ merchants = []
19
+ json["merchants"]["merchant"].each do |merchant|
20
+ merchants << Merchant.new(merchant["merchant_code"],merchant["name"])
21
+ end
22
+ return merchants
23
+ end
24
+
25
+ end
26
+ end
27
+ end
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ module Cashstar
2
+ VERSION = "0.0.2"
3
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cashstar
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
11
+ platform: ruby
12
+ authors:
13
+ - Charlie White
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-04-02 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rest-client
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 13
30
+ segments:
31
+ - 1
32
+ - 6
33
+ - 1
34
+ version: 1.6.1
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: CashStar's API provides a simple interface for purchasing and issuing electronic gift cards from a variety of brands
38
+ email:
39
+ - cwhite@cashstar.com
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ extra_rdoc_files: []
45
+
46
+ files:
47
+ - .gitignore
48
+ - Gemfile
49
+ - Rakefile
50
+ - cashstar.gemspec
51
+ - lib/cashstar.rb
52
+ - lib/cashstar/entities.rb
53
+ - lib/cashstar/entities/base.rb
54
+ - lib/cashstar/entities/catalog.rb
55
+ - lib/cashstar/entities/error.rb
56
+ - lib/cashstar/entities/faceplate.rb
57
+ - lib/cashstar/entities/gift_card.rb
58
+ - lib/cashstar/entities/merchant.rb
59
+ - lib/cashstar/entities/order.rb
60
+ - lib/cashstar/entities/payment.rb
61
+ - lib/cashstar/version.rb
62
+ has_rdoc: true
63
+ homepage: http://www.cashstar.com
64
+ licenses: []
65
+
66
+ post_install_message:
67
+ rdoc_options: []
68
+
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ requirements: []
90
+
91
+ rubyforge_project: cashstar
92
+ rubygems_version: 1.6.2
93
+ signing_key:
94
+ specification_version: 3
95
+ summary: Ruby Bindings for the CashStar API
96
+ test_files: []
97
+