cordial 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9834a9b273a4f75b86bdb25a525f06a7741f07d9
4
- data.tar.gz: f5c9a349b0cbf7d11288315f2dae72f94e2a7880
2
+ SHA256:
3
+ metadata.gz: 9089db5704b706616ddb2dbb61d3bf9c39ab1d1d913a65010e106392922129fd
4
+ data.tar.gz: 302c5bd555e14a08724574e49e6b56d50841b3f5fcb1f5d2aa1fa84e44b676fe
5
5
  SHA512:
6
- metadata.gz: 8e47545046595421b9362b63f6accd536b8770c2101da2b65f700f3d7a0dd239f8c969480075cae940a4ea21d203faf10aabf93ab45753864daf503c00dbf762
7
- data.tar.gz: 53bcd80e70a65ac88fc6665c3948fe2d8623828918eb97868ffc6c9bb7c1a3706e21376d449be99f14001af23ae9c63017f1c51fef8ecd1f40e6b6c7eecf4fd3
6
+ metadata.gz: 3ef85ffef892870a0ca98c312b87f3ab353c17f3921f6a8ae15f62382e00f8c21fa27ba6eb1cf29b84b3b639c41bf5daedbfec286dd7b8c8ccffab4332c3f79a
7
+ data.tar.gz: 78d3a5ab621cc4674aba5e9b6e927da3a97c2af047ac94b6d6fc3664c237e19eaf9419e897cf2a0e163d9d1fdc4bc462465b05e180dfed05a6de8045902a05c5
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  .rspec_status
13
13
 
14
14
  .env
15
+ .env.test
data/.rubocop.yml ADDED
@@ -0,0 +1,4 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ Style/FrozenStringLiteralComment:
4
+ Enabled: false
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,37 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2018-09-10 16:19:18 -0700 using RuboCop version 0.59.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 7
10
+ # Configuration parameters: CountComments, ExcludedMethods.
11
+ # ExcludedMethods: refine
12
+ Metrics/BlockLength:
13
+ Max: 97
14
+
15
+ # Offense count: 2
16
+ # Configuration parameters: CountComments.
17
+ Metrics/MethodLength:
18
+ Max: 19
19
+
20
+ # Offense count: 2
21
+ # Configuration parameters: CountKeywordArgs.
22
+ Metrics/ParameterLists:
23
+ Max: 7
24
+
25
+ # Offense count: 3
26
+ Style/Documentation:
27
+ Exclude:
28
+ - 'spec/**/*'
29
+ - 'test/**/*'
30
+ - 'lib/cordial.rb'
31
+ - 'lib/utils/compact.rb'
32
+
33
+ # Offense count: 14
34
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
35
+ # URISchemes: http, https
36
+ Metrics/LineLength:
37
+ Max: 328
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in cordial.gemspec
6
6
  gemspec
data/History.md ADDED
@@ -0,0 +1,89 @@
1
+ v0.1.10 / 2018-09-07
2
+ ====================
3
+
4
+ * Bump version
5
+ * Add Automation templates send endpoint
6
+ * Bump version
7
+ * Add Automation templates post endpoint
8
+
9
+ v0.1.8 / 2018-08-29
10
+ ===================
11
+
12
+ * Bump Version
13
+ * Update product create method to manage optional parameters
14
+
15
+ v0.1.7 / 2018-08-27
16
+ ===================
17
+
18
+ * Bump Version
19
+ * Avoid send mcID nil values
20
+
21
+ v0.1.6 / 2018-08-13
22
+ ===================
23
+
24
+ * Bump Version
25
+ * Update unsubscribe method
26
+ * Add VCR Gem
27
+
28
+ v0.1.5 / 2018-08-07
29
+ ===================
30
+
31
+ * Bump Version
32
+ * Add linkID and mcID in order create method
33
+
34
+ v0.1.4 / 2018-07-02
35
+ ===================
36
+
37
+ * Bump version
38
+ * Add Cordial::Orders find and create
39
+ * Update product documentation
40
+
41
+ v0.1.3 / 2018-06-25
42
+ ===================
43
+
44
+ * Bump gem version
45
+ * Add more ruby versions to Travis
46
+ * Add compact Hash method
47
+
48
+ v0.1.2 / 2018-06-18
49
+ ===================
50
+
51
+ * Update Version
52
+ * Add Create Product method
53
+ * Add Cordial::Products
54
+ * Add subscribe status to Contacts#create
55
+ * Add CodeClimate reporter to travis
56
+ * Use default travis config
57
+ * bump ruby version
58
+ * Update rake requirement to ~> 12.3
59
+ * Use new CodeClimate badges
60
+ * Add YARDoc to Contacts
61
+ * Remove unused config attribute api_url
62
+ * Add badges and more to readme
63
+
64
+ v0.1.1 / 2018-05-07
65
+ ===================
66
+
67
+ * Bump to 0.1.1
68
+ * Add unsubscribe method
69
+ * Fix Style details
70
+ * Remove unneeded stuff from gemspec
71
+ * Add MIT license
72
+ * Lock dependencies
73
+ * Lock all dev dependencies
74
+ * Add simplecov
75
+ * Add Cordial::Contact.new to create contacts
76
+ * Move base_uri to the client helper
77
+ * Configure gem for test suite
78
+ * Add .env.test
79
+ * Add Cordial::Contacts
80
+ * Add Cordial api client w/basic auth
81
+ * Configure local test environment
82
+ * Add dotenv
83
+ * Add ability to configure the gem
84
+ * Add pry
85
+ * Depend on httparty
86
+ * Add .ruby-version
87
+ * Remove dummy spec
88
+ * Update gemspec with required information
89
+ * Initial commit
data/README.md CHANGED
@@ -1,6 +1,5 @@
1
1
  # Cordial
2
2
 
3
- [ ![Codeship Status for MeUndies/cordial](https://app.codeship.com/projects/ecb6fbe0-2a65-0136-d9ce-769c4cc8653c/status?branch=master)](https://app.codeship.com/projects/287555)
4
3
  [![Gem Version](https://badge.fury.io/rb/cordial.svg)](https://badge.fury.io/rb/cordial)
5
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/a53de2aaf1773c8cfb06/maintainability)](https://codeclimate.com/github/MeUndies/cordial/maintainability)
6
5
  [![Test Coverage](https://api.codeclimate.com/v1/badges/a53de2aaf1773c8cfb06/test_coverage)](https://codeclimate.com/github/MeUndies/cordial/test_coverage)
@@ -37,9 +36,24 @@ Cordial::Contact.create(email: 'hello@world')
37
36
 
38
37
  ## Development
39
38
 
40
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
39
+ To get started you're going to need to get a Cordial api key.
41
40
 
42
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
41
+ After checking out the repo, run `bin/setup` to install dependencies. Then
42
+ update your `.env` files with your api key. Then, run `rake spec` to run the
43
+ tests. You can also run `bin/console` for an interactive prompt that will allow
44
+ you to experiment.
45
+
46
+ To install this gem onto your local machine, run `bundle exec rake install`. To
47
+ release a new version, update the version number in `version.rb`, and then run
48
+ `bundle exec rake release`, which will create a git tag for the version, push
49
+ git commits and tags, and push the `.gem` file to
50
+ [rubygems.org](https://rubygems.org).
51
+
52
+ ## Tests
53
+
54
+ Once you've setup your environment you can run the tests with `rake spec`. In
55
+ order to re-record VCR cassettes you'll want to make sure you have the following
56
+ env var set as follows: `VCR=all`.
43
57
 
44
58
  ## Contributing
45
59
 
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
data/bin/console CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "dotenv/load"
5
- require "cordial"
3
+ require 'bundler/setup'
4
+ require 'dotenv/load'
5
+ require 'cordial'
6
6
 
7
7
  Cordial.configure do |config|
8
8
  config.api_key = ENV['API_KEY']
9
9
  end
10
10
 
11
- require "pry"
11
+ require 'pry'
12
12
  Pry.start
data/bin/setup CHANGED
@@ -5,3 +5,4 @@ set -vx
5
5
 
6
6
  bundle install
7
7
  cp -i .env.sample .env
8
+ cp -i .env.sample .env.test
data/cordial.gemspec CHANGED
@@ -1,32 +1,33 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "cordial/version"
3
+ require 'cordial/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "cordial"
6
+ spec.name = 'cordial'
8
7
  spec.version = Cordial::VERSION
9
- spec.authors = ["Andrew Hood"]
10
- spec.email = ["andrewhood125@gmail.com"]
8
+ spec.authors = ['Andrew Hood']
9
+ spec.email = ['andrewhood125@gmail.com']
11
10
 
12
- spec.summary = "Cordial API Client"
13
- spec.description = "Wraps the Cordial REST API for use inside Ruby applications."
14
- spec.homepage = "https://github.com/MeUndies/cordial"
11
+ spec.summary = 'Cordial API Client'
12
+ spec.description = 'Wraps the Cordial REST API for use inside Ruby applications.'
13
+ spec.homepage = 'https://github.com/MeUndies/cordial'
15
14
 
16
15
  spec.license = 'MIT'
17
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
17
  f.match(%r{^(test|spec|features)/})
19
18
  end
20
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
21
20
 
22
- spec.add_dependency "httparty", "~> 0.16"
21
+ spec.add_dependency 'httparty', '~> 0.16'
22
+ spec.add_dependency 'hashie', '~> 3.5'
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.15"
25
- spec.add_development_dependency "rake", "~> 12.3"
26
- spec.add_development_dependency "rspec", "~> 3.0"
27
- spec.add_development_dependency "pry", "~> 0.11"
28
- spec.add_development_dependency "dotenv", "~> 2.4"
29
- spec.add_development_dependency "simplecov", "~> 0.16"
30
- spec.add_development_dependency "vcr", "~> 4.0"
31
- spec.add_development_dependency "webmock", "~> 3.4.0"
24
+ spec.add_development_dependency 'bundler', '~> 1.15'
25
+ spec.add_development_dependency 'dotenv', '~> 2.4'
26
+ spec.add_development_dependency 'pry', '~> 0.11'
27
+ spec.add_development_dependency 'rake', '~> 12.3'
28
+ spec.add_development_dependency 'rspec', '~> 3.0'
29
+ spec.add_development_dependency 'rubocop', '~> 0.59'
30
+ spec.add_development_dependency 'simplecov', '~> 0.16'
31
+ spec.add_development_dependency 'vcr', '~> 4.0'
32
+ spec.add_development_dependency 'webmock', '~> 3.4.0'
32
33
  end
@@ -41,13 +41,13 @@ module Cordial
41
41
  baseAggregation: base_aggregation,
42
42
  message: {
43
43
  headers: {
44
- subject: headers[:subject_email],
45
- fromEmail: headers[:from_email],
46
- replyEmail: headers[:reply_email],
47
- fromDesc: headers[:from_description]
44
+ subject: headers[:subject_email],
45
+ fromEmail: headers[:from_email],
46
+ replyEmail: headers[:reply_email],
47
+ fromDesc: headers[:from_description]
48
48
  },
49
49
  content: {
50
- "text/html": content[:text]
50
+ "text/html": content[:text]
51
51
  }
52
52
  }
53
53
  }.to_json)
@@ -0,0 +1,19 @@
1
+ module Cordial
2
+ class Order < Hashie::Dash
3
+ property :orderID
4
+ property :email, required: -> { cID.nil? }, message: 'email is required if cID is not set.'
5
+ property :cID, required: -> { email.nil? }, message: 'cID is required if email is not set.'
6
+ property :linkID
7
+ property :status
8
+ property :mcID
9
+ property :storeID
10
+ property :customerID
11
+ property :purchaseDate
12
+ property :shippingAddress
13
+ property :billingAddress
14
+ property :items
15
+ property :tax
16
+ property :shippingAndHandling
17
+ property :properties
18
+ end
19
+ end
@@ -36,36 +36,21 @@ module Cordial
36
36
  end
37
37
 
38
38
  # Create a new order.
39
- # Posting more than one time the same "orderID" name will generate an error.
39
+ #
40
+ # This endpoint does not support the idea of an upsert like others do.
41
+ # Subsequent calls will fail.
40
42
  #
41
43
  # @example Usage.
42
- # Cordial::Orders.create(
43
- # id: 1,
44
- # email: 'cordial@example.com',
45
- # link_id: '123456',
46
- # mc_id: '645:5b6a1f26e1b829b63c2a7946:ot:5aea409bbb3dc2f9bc27158f:1',
47
- # purchase_date: '2015-01-09 17:47:43',
48
- # items: [{productID: '1',
49
- # sku: '123',
50
- # name: 'Test product',
51
- # attr: { color: 'blue', size: 'L' }}])
52
- # @example response whe the orderID is not on cordial
44
+ # Cordial::Orders.create({...})
45
+ #
46
+ # @example response when the orderID is not on cordial
53
47
  # {"success"=>true}
54
48
  #
55
49
  # @example Response when orderID already exist on cordial.
56
50
  # {"error"=>true, "messages"=>"ID must be unique"}
57
- def self.create(id:, email:, purchase_date:, items:, link_id: nil, mc_id: nil)
58
- body = {
59
- orderID: id,
60
- email: email,
61
- purchaseDate: purchase_date,
62
- items: items
63
- }
64
-
65
- body[:linkID] = link_id unless link_id.nil?
66
- body[:mcID] = mc_id unless mc_id.nil?
67
-
68
- client.post('/orders', body: body.to_json)
51
+ def self.create(options)
52
+ order = Cordial::Order.new(options)
53
+ client.post('/orders', body: order.to_json)
69
54
  end
70
55
  end
71
56
  end
@@ -1,3 +1,3 @@
1
1
  module Cordial
2
- VERSION = '0.1.10'.freeze
2
+ VERSION = '0.1.11'.freeze
3
3
  end
data/lib/cordial.rb CHANGED
@@ -1,11 +1,18 @@
1
- require "httparty"
2
- require "utils/compact"
3
- require "cordial/version"
4
- require "cordial/client"
5
- require "cordial/contacts"
6
- require "cordial/products"
7
- require "cordial/orders"
8
- require "cordial/automation_templates"
1
+ require 'hashie'
2
+ require 'httparty'
3
+ require 'utils/compact'
4
+
5
+ require 'cordial/version'
6
+ require 'cordial/client'
7
+
8
+ # Models
9
+ require 'cordial/order'
10
+
11
+ # Controllers
12
+ require 'cordial/contacts'
13
+ require 'cordial/products'
14
+ require 'cordial/orders'
15
+ require 'cordial/automation_templates'
9
16
 
10
17
  module Cordial
11
18
  class << self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cordial
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Hood
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-10 00:00:00.000000000 Z
11
+ date: 2018-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: hashie
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.5'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -39,61 +53,75 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '1.15'
41
55
  - !ruby/object:Gem::Dependency
42
- name: rake
56
+ name: dotenv
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '12.3'
61
+ version: '2.4'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '12.3'
68
+ version: '2.4'
55
69
  - !ruby/object:Gem::Dependency
56
- name: rspec
70
+ name: pry
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '3.0'
75
+ version: '0.11'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '3.0'
82
+ version: '0.11'
69
83
  - !ruby/object:Gem::Dependency
70
- name: pry
84
+ name: rake
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '0.11'
89
+ version: '12.3'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '0.11'
96
+ version: '12.3'
83
97
  - !ruby/object:Gem::Dependency
84
- name: dotenv
98
+ name: rspec
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: '2.4'
103
+ version: '3.0'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: '2.4'
110
+ version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.59'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.59'
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: simplecov
99
127
  requirement: !ruby/object:Gem::Requirement
@@ -144,12 +172,14 @@ extensions: []
144
172
  extra_rdoc_files: []
145
173
  files:
146
174
  - ".env.sample"
147
- - ".env.test"
148
175
  - ".gitignore"
149
176
  - ".rspec"
177
+ - ".rubocop.yml"
178
+ - ".rubocop_todo.yml"
150
179
  - ".ruby-version"
151
180
  - ".travis.yml"
152
181
  - Gemfile
182
+ - History.md
153
183
  - README.md
154
184
  - Rakefile
155
185
  - bin/console
@@ -159,6 +189,7 @@ files:
159
189
  - lib/cordial/automation_templates.rb
160
190
  - lib/cordial/client.rb
161
191
  - lib/cordial/contacts.rb
192
+ - lib/cordial/order.rb
162
193
  - lib/cordial/orders.rb
163
194
  - lib/cordial/products.rb
164
195
  - lib/cordial/version.rb
@@ -183,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
214
  version: '0'
184
215
  requirements: []
185
216
  rubyforge_project:
186
- rubygems_version: 2.5.2
217
+ rubygems_version: 2.7.6
187
218
  signing_key:
188
219
  specification_version: 4
189
220
  summary: Cordial API Client
data/.env.test DELETED
@@ -1 +0,0 @@
1
- API_KEY='cordial-api-key'