acc 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8398dac7711ed3acb08eea64b8b75ef57974809e
4
- data.tar.gz: ef71561e3fcdff2e2c4a957edd43f0efb4c7978e
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YzdkY2ExMWUxNzYyNGQ2Yzk3MDFjNjZiM2ZjZDhmYzI0YTlhMmIyOA==
5
+ data.tar.gz: !binary |-
6
+ ZjdmNmM3MjljYWNmZWE5Mjg0OThmYWFiNDY4NmIyM2VkYTFlNGY4ZQ==
5
7
  SHA512:
6
- metadata.gz: 9600a3fe8d522efeb5546f80e6cb12b7876ad0beee54fcc53493b0503a3eaa33f6423eaf96e5b309092cca4d40dc4bbeaadcb6f7a1bde20617f1248b5211650b
7
- data.tar.gz: c90eb0994bb3663462dac9b348cf6fad8e730fe2c3caef37083b4df787db82e79e887048e50322d2f1d08db269bac8392a4986d2dfeb13d72bdcc9170907d020
8
+ metadata.gz: !binary |-
9
+ NmEzYTY2NjZiOWIyNjIwMjY4OTA0YmJkZmIyOTU2NGI5ZTBhYWIxZTE0MDRj
10
+ NDM0NjVhMjFlOWIzNmQxMjRiMGFlOTQ1YjQ3YmVmMWJmZjg3NGE1YmFlMDU5
11
+ MzNlOWU3OGQ5NDEwM2RkYWQ0MDcwMmRkOGQ1NmNjZDE1NWI0ZDE=
12
+ data.tar.gz: !binary |-
13
+ YjYxNzk1MWRmMGEzM2IxMDY3NTJlZDg0YTFhZjE1NDcxOGNmYzc3YzkwODY3
14
+ YWE3NjIyYTVmNzIyYzQ5ZGM2ZjgzNDZiOGM3NjE4Y2YwMzk3MThlNTc2OTA5
15
+ M2Y5YTFkNDAzOTU3NWE4ZjZkM2VkOGQzMmRhMDM3OTYxNTE2MmY=
@@ -1,4 +1,12 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.2
3
+ - 2.2.2
4
4
  before_install: gem install bundler -v 1.10.6
5
+ deploy:
6
+ provider: rubygems
7
+ api_key:
8
+ secure: kv9NIdYQH+JQD2eBWr2hFJ4F9QWZALHqTDd6moPrfCz8LhH6e5/taGBIjNxbx3dndUu9C9hDXHgd7zkdE/ZXXmiixy7TZifFgbCreRaBaEXpI1pgowthagNXwngDBs+CU6BjwvjLtdmodvYJcmVpSwbc+56+fdCFIA8Z1nhwyopl0Y7EJNLVYKeRCPmrL3eu/U8yVcx78OxP3XU8hEa4BzG6IxXZpEEI3qDBpY0LmsydvqOgXLo4ZeD+ZgSe7s0n4dV+DwYN+SNx5tsZQIVRRYCf/U9nWb8OxDvhPKZa3SYMs7RiUVsY1pN0gtfLNmqEnC1XHXkKLbRTe1yB5Gm3ueIYtGPeSme6gOFrK2q655v5e/+NNoB/r5igYfaPJT/MtJEfxFD3LbqyssIi8drY5fI9FpOc9z3zLMADob3K+yxpMXTb8tmWXzv2znqm2E62OhHkafCUoL9+6B1S+50T5e8S3Z3ocH7dTsrQLZMd4pKBk8ZFwHWmKqNTI1m3wiIgZit/wWX2LvWyIaIixwPwTZbkVIwDolK0Y0iML9RPX4tll29Ms3IUfDwvMjMWOjmWnNptiIHMPOQMZKXezeKRBDovWD12dRs4TOd6L5Zyv5MzUJp5z34dEEL8xniouxPQdfkYhtrcWx5hNMjvZVVChr0P+CzAoJDtI3yZeZMA60Y=
9
+ gem: acc
10
+ on:
11
+ tags: true
12
+ repo: nsarno/acc
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "minitest"
24
24
 
25
25
  spec.add_dependency "curb"
26
+ spec.add_dependency "activesupport"
26
27
  end
data/lib/acc.rb CHANGED
@@ -1,10 +1,22 @@
1
- require "acc/version"
1
+ require 'acc/version'
2
+ require 'active_support'
2
3
 
3
4
  module Acc
4
- BULK_ENROLL_URL = 'https://api-applecareconnect-ept.apple.com/enroll-service/1.0/bulk-enroll-devices'
5
- CHECK_TRANSACTION_URL = 'https://api-applecareconnect-ept.apple.com/enroll-service/1.0/check-transaction-status'
6
- SHOW_ORDER_URL = 'https://api-applecareconnect-ept.apple.com/enroll-service/1.0/show-order-details'
7
- CERTIFICATE_PATH = Rails.env.production? ? 'config/certificate.pem' : 'config/certificate.pfx'
5
+ mattr_accessor :bulk_enroll_endpoint
6
+ self.bulk_enroll_endpoint = 'https://api-applecareconnect-ept.apple.com/enroll-service/1.0/bulk-enroll-devices'
7
+
8
+ mattr_accessor :check_transaction_endpoint
9
+ self.check_transaction_endpoint = 'https://api-applecareconnect-ept.apple.com/enroll-service/1.0/check-transaction-status'
10
+
11
+ mattr_accessor :show_order_endpoint
12
+ self.show_order_endpoint = 'https://api-applecareconnect-ept.apple.com/enroll-service/1.0/show-order-details'
13
+
14
+ mattr_accessor :certificate_path
15
+ self.certificate_path = 'config/certificate.pem'
16
+
17
+ def self.setup
18
+ yield self
19
+ end
8
20
  end
9
21
 
10
22
  require 'acc/bulk_enroll_response'
@@ -4,7 +4,7 @@ class Acc::BulkEnrollResponse
4
4
  end
5
5
 
6
6
  def error?
7
- error_response.present?
7
+ !error_response.nil?
8
8
  end
9
9
 
10
10
  def success?
@@ -12,14 +12,14 @@ class Acc::BulkEnrollResponse
12
12
  end
13
13
 
14
14
  def error_messages
15
- error_response.collect { |e| e['errorMessage'] }
15
+ error_response.nil? ? [] : error_response.collect { |e| e['errorMessage'] }
16
16
  end
17
17
 
18
18
  def data
19
19
  {
20
20
  dep_transaction_id: @response['deviceEnrollmentTransactionId'],
21
21
  status_message: @response['enrollDevicesResponse']['statusMessage']
22
- }
22
+ } if self.success?
23
23
  end
24
24
 
25
25
  private
@@ -30,6 +30,6 @@ class Acc::BulkEnrollResponse
30
30
  end
31
31
 
32
32
  def ship_to_error_response
33
- @response if @response['errorMessage'].present?
33
+ @response unless @response['errorMessage'].nil?
34
34
  end
35
35
  end
@@ -4,10 +4,11 @@ class Acc::CheckTransactionResponse
4
4
  end
5
5
 
6
6
  def error?
7
- ship_to_error? ||
8
- error_response.present? ||
9
- @response['statusCode'] == 'ERROR' ||
10
- @response['statusCode'] == 'COMPLETE_WITH_ERRORS'
7
+ !error_response.nil? || ship_to_error? || order_error?
8
+ end
9
+
10
+ def order_error?
11
+ @response['statusCode'] == 'ERROR' || @response['statusCode'] == 'COMPLETE_WITH_ERRORS'
11
12
  end
12
13
 
13
14
  def complete?
@@ -20,11 +21,11 @@ class Acc::CheckTransactionResponse
20
21
 
21
22
 
22
23
  def in_progress_array_error?
23
- error_response.present? && error_response.first['errorCode'] == 'DEP-ERR-4003'
24
+ !error_response.nil? && error_response.first['errorCode'] == 'DEP-ERR-4003'
24
25
  end
25
26
 
26
27
  def in_progress_error?
27
- error_response.present? && error_response['errorCode'] == 'DEP-ERR-4003'
28
+ !error_response.nil? && error_response['errorCode'] == 'DEP-ERR-4003'
28
29
  end
29
30
 
30
31
  def success?
@@ -33,7 +34,7 @@ class Acc::CheckTransactionResponse
33
34
 
34
35
  def error_messages
35
36
  messages = [ship_to_error_message] + [single_error_message] + multiple_error_messages
36
- messages.delete_if? { |k, v| v.blank? }
37
+ messages.delete_if { |msg| msg.nil? }
37
38
  end
38
39
 
39
40
  def data
@@ -42,24 +43,26 @@ class Acc::CheckTransactionResponse
42
43
 
43
44
  private
44
45
  def ship_to_error?
45
- @response['errorCode'].present?
46
+ !@response['errorCode'].nil?
46
47
  end
47
48
 
48
49
  def error_response
49
50
  @response['checkTransactionErrorResponse']
50
51
  end
51
52
 
52
- def ship_to_error_response
53
+ def ship_to_error_message
53
54
  @response['errorMessage']
54
55
  end
55
56
 
56
57
  def single_error_message
57
- error_response['errorMessage'] if error_response.present?
58
+ error_response['errorMessage'] unless error_response.nil? || error_response.kind_of?(Array)
58
59
  end
59
60
 
60
61
  def multiple_error_messages
61
- if error_response.present? && error_response.kind_of?(Array)
62
+ if !error_response.nil? && error_response.kind_of?(Array)
62
63
  error_response.collect { |e| e['errorMessage'] }
64
+ else
65
+ []
63
66
  end
64
67
  end
65
68
  end
@@ -1,3 +1,3 @@
1
1
  module Acc
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,69 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud MESUREUR
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-11 00:00:00.000000000 Z
11
+ date: 2015-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - ! '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: curb
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activesupport
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  description: Interface for the ACC Device Enrollment Program API
@@ -73,8 +87,8 @@ executables: []
73
87
  extensions: []
74
88
  extra_rdoc_files: []
75
89
  files:
76
- - ".gitignore"
77
- - ".travis.yml"
90
+ - .gitignore
91
+ - .travis.yml
78
92
  - Gemfile
79
93
  - LICENSE
80
94
  - README.md
@@ -96,12 +110,12 @@ require_paths:
96
110
  - lib
97
111
  required_ruby_version: !ruby/object:Gem::Requirement
98
112
  requirements:
99
- - - ">="
113
+ - - ! '>='
100
114
  - !ruby/object:Gem::Version
101
115
  version: '0'
102
116
  required_rubygems_version: !ruby/object:Gem::Requirement
103
117
  requirements:
104
- - - ">="
118
+ - - ! '>='
105
119
  - !ruby/object:Gem::Version
106
120
  version: '0'
107
121
  requirements: []