finerworks 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3c4c9dc051625f149a4d8ee5ca48de3f13c92b7
4
- data.tar.gz: d29862702db6a733cf04ec084949d98dde9b7519
3
+ metadata.gz: 2ba637f8dae31b5c41546a331d7cc046bd50e3fc
4
+ data.tar.gz: d785cff89b74be3121fec4fe8aa358ead878966a
5
5
  SHA512:
6
- metadata.gz: d25b11d9c70ccb35e4abbbd29fe078c97707a598e91e55bea23a6669f0bfe9d88baa7efbe9f95c044d3c28e0662d88bc40580bdd7aa1b05766a028f2fa383cfd
7
- data.tar.gz: db84180174265d98f3a6f54baf09efe344ce4250c5746dc4657ac4ba5fb5c174164c8a33864c8e7002cad2654e1f1e24caf4915268969f421a067148bf1cd309
6
+ metadata.gz: 088365b075195dffef0939c953d0aae066ad18270cea3080ba4fe94332b2839282737a46b00f0099d4a7138872778feec20d32efc46309ed570a1ba62119398e
7
+ data.tar.gz: 15c67e8d1ea13b60d493503af9d474f729a0ff89f81c178b29740ec4d62bfb1d26f8482ae41dd45c0f868a6191a5d5e2cc2b205418c701aee3044b95618f83a1
data/lib/finerworks.rb CHANGED
@@ -1,3 +1,2 @@
1
1
  require 'hashie'
2
- require 'finerworks/utilities'
3
2
  require 'finerworks/client'
@@ -1,3 +1,5 @@
1
+ require 'time'
2
+
1
3
  module FinerWorks
2
4
  class Account < Hashie::Trash
3
5
  property :business_company_name, from: "AccountBusinessCompanyName"
@@ -13,7 +15,7 @@ module FinerWorks
13
15
  property :business_phone, from: "AccountBusinessPhone"
14
16
  property :business_fax, from: "AccountBusinessFax"
15
17
  property :username, from: "AccountUsername"
16
- property :registration_date, from: "AccountRegistrationDate", transform_with: lambda { |d| FinerWorks::Utilities.parse_api_time(d) }
18
+ property :registration_date, from: "AccountRegistrationDate", transform_with: lambda { |d| Time.parse(d) }
17
19
  property :email, from: "AccountEmail"
18
20
  property :type, from: "AccountType"
19
21
  property :first_name, from: "AccountFirstName"
@@ -1,3 +1,5 @@
1
+ require 'time'
2
+
1
3
  module FinerWorks
2
4
  class Image < Hashie::Trash
3
5
  property :guid, from: "ImageGUID"
@@ -5,13 +7,13 @@ module FinerWorks
5
7
  property :url_thumbnail, from: "ImageUrl_Thumbnail"
6
8
  property :original_file_name, from: "ImageOriginalFileName"
7
9
  property :file_name, from: "ImageFileName"
8
- property :date_added, from: "ImageDateAdded", transform_with: lambda { |d| FinerWorks::Utilities.parse_api_time(d) }
10
+ property :date_added, from: "ImageDateAdded", transform_with: lambda { |d| Time.parse(d) }
9
11
  property :active, from: "ImageActive", transform_with: lambda { |value| value == "True" }
10
12
  property :file_size, from: "ImageFileSize"
11
13
  property :w, from: "ImageW"
12
14
  property :h, from: "ImageH"
13
15
  property :title, from: "ImageTitle"
14
- property :date_updated, from: "ImageDateUpdated", transform_with: lambda { |d| FinerWorks::Utilities.parse_api_time(d) }
16
+ property :date_updated, from: "ImageDateUpdated", transform_with: lambda { |d| Time.parse(d) }
15
17
  property :rank, from: "ImageRank"
16
18
  property :order, from: "ImageOrder"
17
19
  property :rating, from: "ImageRating"
@@ -1,8 +1,10 @@
1
+ require 'time'
2
+
1
3
  module FinerWorks
2
4
  class Order < Hashie::Trash
3
5
  property :id, from: "OrderID"
4
6
  property :grand_total, from: "OrderGrandTotal"
5
- property :date_time, from: "OrderDateTime", transform_with: lambda { |d| FinerWorks::Utilities.parse_api_time(d) }
7
+ property :date_time, from: "OrderDateTime", transform_with: lambda { |d| Time.parse(d) }
6
8
  property :drop_ship, from: "OrderDropShip"
7
9
  property :status_id, from: "OrderStatusID"
8
10
  property :status_label, from: "OrderStatusLabel"
@@ -1,3 +1,5 @@
1
+ require 'time'
2
+
1
3
  module FinerWorks
2
4
  class Print < Hashie::Trash
3
5
  property :add_on_title, from: "AddOnTitle"
@@ -8,7 +10,7 @@ module FinerWorks
8
10
  property :image_title, from: "ImageTitle"
9
11
  property :media_name, from: "MediaName"
10
12
  property :mounting_name, from: "MountingName"
11
- property :date_added, from: "PrintDateAdded", transform_with: lambda { |d| FinerWorks::Utilities.parse_api_time(d) }
13
+ property :date_added, from: "PrintDateAdded", transform_with: lambda { |d| Time.parse(d) }
12
14
  property :description, from: "PrintDescription"
13
15
  property :guid, from: "PrintGUID"
14
16
  property :media_id, from: "PrintMediaID"
@@ -4,6 +4,7 @@ require 'net/http'
4
4
  module FinerWorks
5
5
  class Request
6
6
  BASE_URL = "http://api.finerworks.com/api"
7
+ TIME_ZONE_ID = "UTC"
7
8
 
8
9
  def self.get(client, path, options = {})
9
10
  path.prepend("/") if !path.start_with?("/")
@@ -11,7 +12,7 @@ module FinerWorks
11
12
  options.each do |option|
12
13
  params = params + "&#{option[0].to_s}=#{option[1]}"
13
14
  end
14
- uri = URI.parse("#{BASE_URL}#{path}?AccountApiKey=#{client.account_api_key}#{params}")
15
+ uri = URI.parse("#{BASE_URL}#{path}?AccountApiKey=#{client.account_api_key}&TimeZoneID=#{TIME_ZONE_ID}#{params}")
15
16
  http = Net::HTTP.new(uri.host, uri.port)
16
17
  request = Net::HTTP::Get.new(uri.request_uri)
17
18
  response = http.request(request)
@@ -20,7 +21,7 @@ module FinerWorks
20
21
 
21
22
  def self.post(client, path, options = {})
22
23
  path.prepend("/") if !path.start_with?("/")
23
- uri = URI.parse("#{BASE_URL}#{path}?AccountApiKey=#{client.account_api_key}")
24
+ uri = URI.parse("#{BASE_URL}#{path}?AccountApiKey=#{client.account_api_key}&TimeZoneID=#{TIME_ZONE_ID}")
24
25
  http = Net::HTTP.new(uri.host, uri.port)
25
26
  request = Net::HTTP::Post.new(uri.request_uri)
26
27
  request.body = options.to_json
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: finerworks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Fredrickson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-18 00:00:00.000000000 Z
11
+ date: 2015-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -97,7 +97,6 @@ files:
97
97
  - lib/finerworks/print.rb
98
98
  - lib/finerworks/request.rb
99
99
  - lib/finerworks/response.rb
100
- - lib/finerworks/utilities.rb
101
100
  homepage: https://github.com/jfredrickson/finerworks
102
101
  licenses:
103
102
  - MIT
@@ -108,9 +107,9 @@ require_paths:
108
107
  - lib
109
108
  required_ruby_version: !ruby/object:Gem::Requirement
110
109
  requirements:
111
- - - ">="
110
+ - - "~>"
112
111
  - !ruby/object:Gem::Version
113
- version: '0'
112
+ version: '1.9'
114
113
  required_rubygems_version: !ruby/object:Gem::Requirement
115
114
  requirements:
116
115
  - - ">="
@@ -1,13 +0,0 @@
1
- require 'time'
2
-
3
- module FinerWorks
4
- module Utilities
5
- module_function
6
-
7
- # Parse ISO 8601 time strings from the FinerWorks Web API. This function takes into consideration the fact that
8
- # the FinerWorks API does not specify a time zone in its responses, yet it appears to use US Central Time.
9
- def parse_api_time(time_string)
10
- Time.parse(time_string.split("T").first + "T00:00:00-0600")
11
- end
12
- end
13
- end