fetchapp-api-ruby 1.2.5 → 2.0.0

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/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ v.2.0.0 ** API version 2.0 **
2
+
1
3
  v.1.2.5 Upload Support
2
4
 
3
5
  v.1.2.4 Removed dependency on ActiveRecord and Active Support
data/Manifest CHANGED
@@ -4,9 +4,11 @@ init.rb
4
4
  lib/fetchapp-api-ruby/account.rb
5
5
  lib/fetchapp-api-ruby/base.rb
6
6
  lib/fetchapp-api-ruby/download.rb
7
+ lib/fetchapp-api-ruby/file.rb
7
8
  lib/fetchapp-api-ruby/upload.rb
8
- lib/fetchapp-api-ruby/item.rb
9
+ lib/fetchapp-api-ruby/product.rb
9
10
  lib/fetchapp-api-ruby/order.rb
11
+ lib/fetchapp-api-ruby/order_item.rb
10
12
  lib/fetchapp-api-ruby-ruby.rb
11
13
  LICENSE
12
14
  Manifest
data/README.md CHANGED
@@ -4,52 +4,85 @@
4
4
 
5
5
  # Setup
6
6
  ```ruby
7
- FetchAPI::Base.basic_auth('youraccount.fetchapp.com', 'demokey', 'demotoken')
7
+ FetchAppAPI::Base.basic_auth('demokey', 'demotoken')
8
8
  ```
9
9
  # Account
10
10
  ```ruby
11
- account = FetchAPI::Account.details
11
+ account = FetchAppAPI::Account.details
12
12
 
13
- token = FetchAPI::Account.new_token #Subsequent calls will use the new token automatically
13
+ token = FetchAppAPI::Account.new_token # Subsequent calls will use the new token automatically
14
14
  ```
15
15
  # Downloads
16
16
  ```ruby
17
- downloads = FetchAPI::Download.find(:all, :per_page => 50, :page => 2)
17
+ downloads = FetchAppAPI::Download.find(:all, :per_page => 50, :page => 2)
18
18
 
19
- download = FetchAPI::Download.find(1)
19
+ download = FetchAppAPI::Download.find(1)
20
20
  ```
21
21
 
22
- # Items
22
+ # Products
23
23
  ```ruby
24
- items = FetchAPI::Item.find(:all, :per_page => 10, :page => 3)
24
+ products = FetchAppAPI::Product.find(:all, :per_page => 10, :page => 3)
25
25
 
26
- item = FetchAPI::Item.find("CJ0001")
26
+ product = FetchAppAPI::Product.find("CJ0001")
27
27
 
28
- item = FetchAPI::Item.create(:sku => "CJ0001", :name => "Carrot Juice")
28
+ product = FetchAppAPI::Product.create(:sku => "CJ0001", :name => "Carrot Juice")
29
29
 
30
- item.update(:name => "Tomato Juice")
30
+ product.update(:name => "Tomato Juice")
31
31
 
32
- item.destroy
32
+ product.destroy
33
33
 
34
- downloads = item.downloads #Returns an array of FetchAPI::Downloads for this item
34
+ product.stats # Returns a FetchAppAPI::Product with only statistical fields filled in
35
+
36
+ downloads = product.downloads # Returns an array of FetchAppAPI::Download for this product
37
+
38
+ files = product.files # Returns an array of FetchAppAPI::File for this product
35
39
  ```
36
40
  # Orders
37
41
  ```ruby
38
- all_orders = FetchAPI::Order.find(:all)
42
+ all_orders = FetchAppAPI::Order.find(:all)
39
43
 
40
- current_orders = FetchAPI::Order.find(:current, :page => 3)
44
+ current_orders = FetchAppAPI::Order.find(:current, :page => 3)
41
45
 
42
- manual_orders = FetchAPI::Order.find(:manual, :per_page => 10)
46
+ manual_orders = FetchAppAPI::Order.find(:manual, :per_page => 10)
43
47
 
44
- expired_orders = FetchAPI::Order.find(:expired, :per_page => 10, :page => 3)
48
+ expired_orders = FetchAppAPI::Order.find(:expired, :per_page => 10, :page => 3)
45
49
 
46
- order = FetchAPI::Order.find("1001")
50
+ order = FetchAppAPI::Order.find("1001")
47
51
 
48
- order = FetchAPI::Order.create(:id => "1015", :title => "Test Order", :first_name => "Donald", :last_name => "Duck", :email => "donald@duck.com", :order_items => [{:sku => 'ABC0001'}, {:sku => 'ABC0002}])
52
+ order = FetchAppAPI::Order.create(
53
+ :id => "1015",
54
+ :title => "Test Order",
55
+ :first_name => "Donald",
56
+ :last_name => "Duck",
57
+ :email => "donald@duck.com",
58
+ :order_items => [{:sku => 'ABC0001'}, {:sku => 'ABC0002'}]
59
+ )
49
60
 
50
61
  order.update(:first_name => "Daffy")
51
62
 
52
63
  order.destroy
53
64
 
54
- downloads = order.downloads #Returns an array of FetchAPI::Downloads for this order
65
+ order.expire # Expires the order
66
+
67
+ order.send_email # Reopens the order and sends out an email to the customer
68
+
69
+ order.stats # Returns a FetchAppAPI::Order with only statistical fields filled in
70
+
71
+ order_items = order.order_items # Returns an array of FetchAppAPI::OrderItem for this order
72
+
73
+ downloads = order.downloads # Returns an array of FetchAppAPI::Download for this order
74
+
75
+ ```
76
+
77
+ # OrderItems
78
+ ```ruby
79
+ order_items = order.order_items # Returns an array of FetchAppAPI::OrderItem for this order
80
+
81
+ order_item = FetchAppAPI::Order.find("445566")
82
+
83
+ order_item.expire # Expires the OrderItem
84
+
85
+ downloads = order_item.downloads # Returns an array of FetchAppAPI::Download for this order item
86
+
87
+ files = order_item.files # Returns an array of FetchAppAPI::File for this order item
55
88
  ```
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{fetchapp-api-ruby}
5
- s.version = "1.2.5"
5
+ s.version = "2.0.0"
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Michael Larkin"]
9
9
  s.date = Date.today.strftime('%Y-%m-%d')
10
10
  s.description = %q{Integrate your site with http://fetchapp.com for seamless digital delivery.}
11
11
  s.email = %q{support@fetchapp.com}
12
- s.extra_rdoc_files = ["CHANGELOG", "lib/fetchapp-api-ruby/account.rb", "lib/fetchapp-api-ruby/base.rb", "lib/fetchapp-api-ruby/download.rb", "lib/fetchapp-api-ruby/upload.rb", "lib/fetchapp-api-ruby/item.rb", "lib/fetchapp-api-ruby/order.rb", "lib/fetchapp-api-ruby.rb", "LICENSE", "README.md"]
13
- s.files = ["CHANGELOG", "fetchapp-api-ruby.gemspec", "init.rb", "lib/fetchapp-api-ruby/account.rb", "lib/fetchapp-api-ruby/base.rb", "lib/fetchapp-api-ruby/download.rb", "lib/fetchapp-api-ruby/upload.rb", "lib/fetchapp-api-ruby/item.rb", "lib/fetchapp-api-ruby/order.rb", "lib/fetchapp-api-ruby.rb", "LICENSE", "Manifest", "Rakefile", "README.md"]
12
+ s.extra_rdoc_files = ["CHANGELOG", "lib/fetchapp-api-ruby/account.rb", "lib/fetchapp-api-ruby/base.rb", "lib/fetchapp-api-ruby/download.rb", "lib/fetchapp-api-ruby/upload.rb", "lib/fetchapp-api-ruby/product.rb", "lib/fetchapp-api-ruby/order.rb", "lib/fetchapp-api-ruby/order_item.rb", "lib/fetchapp-api-ruby/file.rb", "lib/fetchapp-api-ruby.rb", "LICENSE", "README.md"]
13
+ s.files = ["CHANGELOG", "fetchapp-api-ruby.gemspec", "init.rb", "lib/fetchapp-api-ruby/account.rb", "lib/fetchapp-api-ruby/base.rb", "lib/fetchapp-api-ruby/download.rb", "lib/fetchapp-api-ruby/upload.rb", "lib/fetchapp-api-ruby/order_item.rb", "lib/fetchapp-api-ruby/file.rb", "lib/fetchapp-api-ruby/product.rb", "lib/fetchapp-api-ruby/order.rb", "lib/fetchapp-api-ruby.rb", "LICENSE", "Manifest", "Rakefile", "README.md"]
14
14
  s.has_rdoc = true
15
15
  s.homepage = %q{http://github.com/getsy/fetchapp-api-ruby}
16
16
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "fetchapp-api-ruby", "--main", "README.md"]
@@ -6,6 +6,8 @@ $:.unshift(File.dirname(__FILE__))
6
6
  require 'fetchapp-api-ruby/base'
7
7
  require 'fetchapp-api-ruby/account'
8
8
  require 'fetchapp-api-ruby/download'
9
- require 'fetchapp-api-ruby/upload'
10
- require 'fetchapp-api-ruby/item'
9
+ require 'fetchapp-api-ruby/file'
11
10
  require 'fetchapp-api-ruby/order'
11
+ require 'fetchapp-api-ruby/order_item'
12
+ require 'fetchapp-api-ruby/upload'
13
+ require 'fetchapp-api-ruby/product'
@@ -1,15 +1,15 @@
1
- module FetchAPI
2
- class Account < FetchAPI::Base
3
- attr_accessor :attributes
1
+ module FetchAppAPI
2
+ class Account < FetchAppAPI::Base
3
+ attr_accessor :attributes
4
4
  #--
5
5
  ################ Class Methods ###############
6
6
  #--
7
7
 
8
8
  # Retrieves information about the Account
9
9
  def self.details
10
- account = Account.new({})
11
- account.attributes = execute(:get, "/account")["account"]
12
- account
10
+ account = Account.new({})
11
+ account.attributes = execute(:get, "/account")["account"]
12
+ account
13
13
  end
14
14
 
15
15
  # Generates a new API token. Subsequent API calls using the
@@ -18,7 +18,7 @@ module FetchAPI
18
18
  token = execute(:get, "/new_token")
19
19
  unless token["message"].nil? || token["message"].empty?
20
20
  # Reauthorize
21
- Connector.basic_auth(FetchAPI::Base.key, token["message"])
21
+ Connector.basic_auth(FetchAppAPI::Base.key, token["message"])
22
22
  token
23
23
  end
24
24
  end
@@ -1,4 +1,13 @@
1
- module FetchAPI
1
+
2
+ # Extend the String class to have the handy .blank? method
3
+ class String
4
+ def blank?
5
+ self.empty? || self.nil?
6
+ end
7
+ end
8
+
9
+ module FetchAppAPI
10
+
2
11
  class Base
3
12
  require 'pp'
4
13
 
@@ -35,10 +44,12 @@ module FetchAPI
35
44
  end
36
45
 
37
46
  # Initializes the connection to the API
38
- def self.basic_auth(url, key, token)
39
- @key = key # Save this in case they generate a new token later
40
- Connector.base_uri(url+"/api")
41
- Connector.basic_auth(key, token)
47
+ def self.basic_auth(params={})
48
+ return false if params[:key].blank? || params[:token].blank?
49
+
50
+ @key = params[:key] # Save this in case they generate a new token later
51
+ Connector.base_uri((params[:url] || 'app.fetchapp.com')+"/api/v2")
52
+ Connector.basic_auth(params[:key], params[:token])
42
53
  end
43
54
 
44
55
  def self.key #:nodoc:
@@ -82,11 +93,11 @@ module FetchAPI
82
93
  when 200..299 then
83
94
  response
84
95
  when 300.399 then
85
- raise(response.messsage)
96
+ raise("#{response.message}: #{response['message']}")
86
97
  when 400..499 then
87
- raise(response.message)
98
+ raise("#{response.message}: #{response['message']}")
88
99
  when 500..599 then
89
- raise(response.message)
100
+ raise("#{response.message}: #{response['message']}")
90
101
  else
91
102
  raise("Unknown Response")
92
103
  end
@@ -94,7 +105,7 @@ module FetchAPI
94
105
  end
95
106
 
96
107
 
97
- # Access attributes as class methods of the Item object
108
+ # Access attributes as class methods of the object
98
109
  def method_missing(method) #:nodoc:
99
110
  return super unless attributes.has_key?(method.to_s)
100
111
  attributes[method.to_s]
@@ -1,5 +1,5 @@
1
- module FetchAPI
2
- class Download < FetchAPI::Base
1
+ module FetchAppAPI
2
+ class Download < FetchAppAPI::Base
3
3
  attr_accessor :id, :attributes
4
4
 
5
5
  # Find :all downloads or the specified ID
@@ -0,0 +1,11 @@
1
+ module FetchAppAPI
2
+ class File < FetchAppAPI::Base
3
+ attr_accessor :id, :attributes
4
+
5
+ # Find :all files or the specified ID
6
+ def self.find(selector, params={})
7
+ super(selector, params)
8
+ end
9
+
10
+ end
11
+ end
@@ -1,48 +1,48 @@
1
- module FetchAPI
1
+ module FetchAppAPI
2
2
 
3
- class Order < FetchAPI::Base
3
+ class Order < FetchAppAPI::Base
4
4
  attr_accessor :id, :attributes
5
5
 
6
6
  #--
7
7
  ################ Class Methods ###############
8
8
  #--
9
9
 
10
- # Finds an Order or orders based on the specified parameters
11
- # :all, :current, :manual, :expired, or by ID
10
+ # Finds an Order or orders based on the specified parameters
11
+ # :all, :current, :manual, :expired, or by ID
12
12
  def self.find(selector, params={})
13
13
  case selector
14
- when :current
15
- params.merge!(:filter => "current")
16
- orders = execute(:get, "/orders", params)
17
- if orders["orders"].nil? || orders["orders"].empty?
18
- return []
14
+ when :current
15
+ params.merge!(:filter => "current")
16
+ orders = execute(:get, "/orders", params)
17
+ if orders["orders"].nil? || orders["orders"].empty?
18
+ return []
19
+ else
20
+ orders["orders"].map { |data| new(data) }
21
+ end
22
+ when :manual
23
+ params.merge!(:filter => "manual")
24
+ orders = execute(:get, "/orders", params)
25
+ if orders["orders"].nil? || orders["orders"].empty?
26
+ return []
27
+ else
28
+ orders["orders"].map { |data| new(data) }
29
+ end
30
+ when :expired
31
+ params.merge!(:filter => "expired")
32
+ orders = execute(:get, "/orders", params)
33
+ if orders["orders"].nil? || orders["orders"].empty?
34
+ return []
35
+ else
36
+ orders["orders"].map { |data| new(data) }
37
+ end
19
38
  else
20
- orders["orders"].map { |data| new(data) }
21
- end
22
- when :manual
23
- params.merge!(:filter => "manual")
24
- orders = execute(:get, "/orders", params)
25
- if orders["orders"].nil? || orders["orders"].empty?
26
- return []
27
- else
28
- orders["orders"].map { |data| new(data) }
29
- end
30
- when :expired
31
- params.merge!(:filter => "expired")
32
- orders = execute(:get, "/orders", params)
33
- if orders["orders"].nil? || orders["orders"].empty?
34
- return []
35
- else
36
- orders["orders"].map { |data| new(data) }
37
- end
38
- else
39
- super
39
+ super
40
40
  end
41
41
  end
42
42
 
43
43
  # Creates a new Order
44
44
  def self.create(options={})
45
- return FetchAPI::Order.new(execute(:post, "/orders/create", :order => options)["order"])
45
+ return FetchAppAPI::Order.new(execute(:post, "/orders/create", :order => options)["order"])
46
46
  end
47
47
 
48
48
  #--
@@ -72,11 +72,27 @@ module FetchAPI
72
72
  self.attributes = put("/orders/#{id}", :order => options)["order"]
73
73
  end
74
74
 
75
- # Returns all the downloads associated with this Order
75
+ # Returns all the downloads associated with this Order
76
+ def order_items(params={})
77
+ order_items = get("/orders/#{id}/order_items")
78
+ if order_items
79
+ order_items["order_items"].map { |data| FetchAppAPI::OrderItem.new(data) }
80
+ end
81
+ end
82
+
83
+
84
+ # Returns all the downloads associated with this Order
76
85
  def downloads(params={})
77
86
  downloads = get("/orders/#{id}/downloads")
78
87
  if downloads
79
- downloads["downloads"].map { |data| FetchAPI::Download.new(data) }
88
+ downloads["downloads"].map { |data| FetchAppAPI::Download.new(data) }
89
+ end
90
+ end
91
+
92
+ def stats
93
+ stats = get("/orders/#{id}/stats")
94
+ if stats
95
+ FetchAppAPI::Order.new(stats["order"])
80
96
  end
81
97
  end
82
98
 
@@ -0,0 +1,45 @@
1
+ module FetchAppAPI
2
+
3
+ class OrderItem < FetchAppAPI::Base
4
+ attr_accessor :id, :attributes
5
+
6
+ #--
7
+ ################ Class Methods ###############
8
+ #--
9
+
10
+ # Finds an Order or orders based on the specified parameters
11
+ # :all or by ID
12
+ def self.find(selector, params={})
13
+ super(selector, params)
14
+ end
15
+
16
+ #--
17
+ ################# Instance Methods ###############
18
+ #--
19
+
20
+ # Sets the expiration date to Time.now, stopping future downloads
21
+ def expire
22
+ post("/orders/#{order_id}/order_items/#{id}/expire")
23
+ end
24
+
25
+ # Returns all the downloads associated with this Order
26
+ def downloads(params={})
27
+ downloads = get("/orders/#{order_id}/order_items/#{id}/downloads")
28
+ if downloads
29
+ downloads["downloads"].map { |data| FetchAppAPI::Download.new(data) }
30
+ else
31
+ return []
32
+ end
33
+ end
34
+
35
+ def files(params={})
36
+ files = get("/orders/#{order_id}/order_items/#{id}/files")
37
+ if files
38
+ files["files"].map { |data| FetchAppAPI::File.new(data) }
39
+ else
40
+ return []
41
+ end
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,71 @@
1
+ module FetchAppAPI
2
+ class Product < FetchAppAPI::Base
3
+ attr_accessor :id, :attributes
4
+
5
+ def initialize(id_or_attributes) #:nodoc:
6
+ case id_or_attributes
7
+ when Integer, String
8
+ @attributes = get("/#{self.class.pluralized_class_name}/#{id_or_attributes.to_s}")
9
+ @attributes = @attributes[self.class.singularized_class_name]
10
+ when Hash
11
+ @attributes = id_or_attributes
12
+ end
13
+ end
14
+
15
+
16
+ #--
17
+ ################ Class Methods ###############
18
+ #--
19
+
20
+ # Find :all products or a specific SKU
21
+ def self.find(selector, params={})
22
+ super(selector, params)
23
+ end
24
+
25
+
26
+ # Creates a new Product
27
+ def self.create(options)
28
+ return FetchAppAPI::Product.new(execute(:post, "/products/create", :product => options)["product"])
29
+ end
30
+
31
+ #--
32
+ ################# Instance Methods ###############
33
+ #--
34
+
35
+ # Permanently deletes the Product
36
+ def destroy
37
+ delete("/products/#{self.sku}/delete")
38
+ end
39
+
40
+ # Immediately updates the Product
41
+ def update(options)
42
+ self.attributes = put("/products/#{self.sku}", :product => options)["product"]
43
+ self.id = self.sku
44
+ end
45
+
46
+ # Returns all the downloads associated with this Product
47
+ def downloads
48
+ downloads = get("/products/#{sku}/downloads")
49
+ if downloads
50
+ downloads["downloads"].map { |data| FetchAppAPI::Download.new(data) }
51
+ end
52
+ end
53
+
54
+ # Returns all the downloads associated with this Product
55
+ def files
56
+ files = get("/products/#{sku}/files")
57
+ if files
58
+ files["files"].map { |data| FetchAppAPI::File.new(data) }
59
+ end
60
+ end
61
+
62
+ # Returns stats about this Product
63
+ def stats
64
+ stats = get("/products/#{sku}/stats")
65
+ if stats
66
+ FetchAppAPI::Product.new(stats["product"])
67
+ end
68
+ end
69
+
70
+ end
71
+ end
@@ -1,5 +1,5 @@
1
- module FetchAPI
2
- class Upload < FetchAPI::Base
1
+ module FetchAppAPI
2
+ class Upload < FetchAppAPI::Base
3
3
  attr_accessor :id, :attributes
4
4
 
5
5
  # Find :all uploads or the specified ID
metadata CHANGED
@@ -1,83 +1,67 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: fetchapp-api-ruby
3
- version: !ruby/object:Gem::Version
4
- hash: 21
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 2
9
- - 5
10
- version: 1.2.5
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Michael Larkin
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-04-13 00:00:00 -04:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2012-08-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: httparty
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70198023540320 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
33
22
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: fakeweb
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70198023540320
25
+ - !ruby/object:Gem::Dependency
26
+ name: fakeweb
27
+ requirement: &70198023539340 !ruby/object:Gem::Requirement
39
28
  none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
47
33
  type: :development
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- name: mocha
51
34
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *70198023539340
36
+ - !ruby/object:Gem::Dependency
37
+ name: mocha
38
+ requirement: &70198023538340 !ruby/object:Gem::Requirement
53
39
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
61
44
  type: :development
62
- version_requirements: *id003
45
+ prerelease: false
46
+ version_requirements: *70198023538340
63
47
  description: Integrate your site with http://fetchapp.com for seamless digital delivery.
64
48
  email: support@fetchapp.com
65
49
  executables: []
66
-
67
50
  extensions: []
68
-
69
- extra_rdoc_files:
51
+ extra_rdoc_files:
70
52
  - CHANGELOG
71
53
  - lib/fetchapp-api-ruby/account.rb
72
54
  - lib/fetchapp-api-ruby/base.rb
73
55
  - lib/fetchapp-api-ruby/download.rb
74
56
  - lib/fetchapp-api-ruby/upload.rb
75
- - lib/fetchapp-api-ruby/item.rb
57
+ - lib/fetchapp-api-ruby/product.rb
76
58
  - lib/fetchapp-api-ruby/order.rb
59
+ - lib/fetchapp-api-ruby/order_item.rb
60
+ - lib/fetchapp-api-ruby/file.rb
77
61
  - lib/fetchapp-api-ruby.rb
78
62
  - LICENSE
79
63
  - README.md
80
- files:
64
+ files:
81
65
  - CHANGELOG
82
66
  - fetchapp-api-ruby.gemspec
83
67
  - init.rb
@@ -85,52 +69,45 @@ files:
85
69
  - lib/fetchapp-api-ruby/base.rb
86
70
  - lib/fetchapp-api-ruby/download.rb
87
71
  - lib/fetchapp-api-ruby/upload.rb
88
- - lib/fetchapp-api-ruby/item.rb
72
+ - lib/fetchapp-api-ruby/order_item.rb
73
+ - lib/fetchapp-api-ruby/file.rb
74
+ - lib/fetchapp-api-ruby/product.rb
89
75
  - lib/fetchapp-api-ruby/order.rb
90
76
  - lib/fetchapp-api-ruby.rb
91
77
  - LICENSE
92
78
  - Manifest
93
79
  - Rakefile
94
80
  - README.md
95
- has_rdoc: true
96
81
  homepage: http://github.com/getsy/fetchapp-api-ruby
97
82
  licenses: []
98
-
99
83
  post_install_message:
100
- rdoc_options:
84
+ rdoc_options:
101
85
  - --line-numbers
102
86
  - --inline-source
103
87
  - --title
104
88
  - fetchapp-api-ruby
105
89
  - --main
106
90
  - README.md
107
- require_paths:
91
+ require_paths:
108
92
  - lib
109
- required_ruby_version: !ruby/object:Gem::Requirement
93
+ required_ruby_version: !ruby/object:Gem::Requirement
110
94
  none: false
111
- requirements:
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- hash: 3
115
- segments:
116
- - 0
117
- version: "0"
118
- required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
100
  none: false
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- hash: 11
124
- segments:
125
- - 1
126
- - 2
127
- version: "1.2"
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '1.2'
128
105
  requirements: []
129
-
130
106
  rubyforge_project:
131
- rubygems_version: 1.5.3
107
+ rubygems_version: 1.8.6
132
108
  signing_key:
133
109
  specification_version: 3
134
- summary: This Ruby library allows you to integrate your site with http://fetchapp.com for seamless digital delivery so you can build additional functionality while retaining the core features of Fetch. Credit for the bulk of the code goes to Thomas Reynolds.
110
+ summary: This Ruby library allows you to integrate your site with http://fetchapp.com
111
+ for seamless digital delivery so you can build additional functionality while retaining
112
+ the core features of Fetch. Credit for the bulk of the code goes to Thomas Reynolds.
135
113
  test_files: []
136
-
@@ -1,55 +0,0 @@
1
- module FetchAPI
2
- class Item < FetchAPI::Base
3
- attr_accessor :id, :attributes
4
-
5
- def initialize(id_or_attributes) #:nodoc:
6
- case id_or_attributes
7
- when Integer, String
8
- @attributes = get("/#{self.class.pluralized_class_name}/#{id_or_attributes.to_s}")
9
- @attributes = @attributes[self.class.singularized_class_name]
10
- when Hash
11
- @attributes = id_or_attributes
12
- end
13
- end
14
-
15
-
16
- #--
17
- ################ Class Methods ###############
18
- #--
19
-
20
- # Find :all items or a specific SKU
21
- def self.find(selector, params={})
22
- super(selector, params)
23
- end
24
-
25
-
26
- # Creates a new Item
27
- def self.create(options)
28
- return FetchAPI::Item.new(execute(:post, "/items/create", :item => options)["item"])
29
- end
30
-
31
- #--
32
- ################# Instance Methods ###############
33
- #--
34
-
35
- # Permanently deletes the Item
36
- def destroy
37
- delete("/items/#{sku}/delete")
38
- end
39
-
40
- # Immediately updates the Item
41
- def update(options)
42
- self.attributes = put("/items/#{sku}", :item => options)["item"]
43
- self.id = self.sku
44
- end
45
-
46
- # Returns all the downloads associated with this Item
47
- def downloads
48
- downloads = get("/items/#{sku}/downloads")
49
- if downloads
50
- downloads["downloads"].map { |data| FetchAPI::Download.new(data) }
51
- end
52
- end
53
-
54
- end
55
- end