tyreshopper_sqs2cb 0.0.2 → 0.0.3

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
2
  SHA1:
3
- metadata.gz: cff962d702de6839c46b2fc005d001a0fbcd5127
4
- data.tar.gz: 1797dcdbbe5646e02ff4d9c0758dace32f5f4c2b
3
+ metadata.gz: 24b815533486530635df49b3593197ba84ccd2a7
4
+ data.tar.gz: 93008476a8cca8c5039bd4e57ce0ceec68d9cea2
5
5
  SHA512:
6
- metadata.gz: da9e42a533c48fed2528b87b618b1772dde32704a768263bc236147a90923a1f0271af19fd596866f42d3ac6eb0c56139795e80f6e5fa7aff3791b1c8ff0f04d
7
- data.tar.gz: 99ed585f27028a60f3aed0bb1384c898596916fe5a6c23748b158002f5cf337cfa3df1a169883bd8b6b29da253735da24da0172d9f4d81cf5baababac223a9e9
6
+ metadata.gz: 5178025b4ccfdfaaac65be8c759ee93471677e368ce3da45c81bc6b62c8151a010d8d24353c862172543e3ea6d528eafe2f450e1cba1ea53a27dd8fc2c19ccfc
7
+ data.tar.gz: 90457f7265da89d39b07d48028a2e9b098fd420f27ca64daefa818343f2f4029b873dd245189772d4e869aa5d14a66f0d77c512e4b0012aa9767a0eb4b69793b
@@ -12,7 +12,7 @@ module TyreshopperSqs2cb
12
12
  def initialize
13
13
 
14
14
  logfile = ENV['TYRESHOPPER_SQS2CB_LOGFILE_PATH'].nil? ? STDOUT : File.open(ENV['TYRESHOPPER_SQS2CB_LOGFILE_PATH'], 'a')
15
- logfile = STDOUT
15
+ logfile.sync = true
16
16
  @logger = Logger.new logfile
17
17
 
18
18
 
@@ -34,7 +34,7 @@ module TyreshopperSqs2cb
34
34
  @options = options
35
35
  @logger.info "Tyreshopper Message received."
36
36
  @logger.debug message.body
37
- puts "Sending..."
37
+ @logger.info "Sending..."
38
38
 
39
39
  @caseBlocksAPIEndpoint = options[:case_blocks_api_endpoint]
40
40
  @caseBlocksAPIToken = options[:caseblocks_api_token]
@@ -54,17 +54,17 @@ module TyreshopperSqs2cb
54
54
  def send_to_caseblocks(msgHash)
55
55
  @logger.info "Sending to CaseBlocks"
56
56
 
57
- puts "Sending order #{msgHash["case"]["title"]} to caseblocks..."
57
+ @logger.info "Sending order #{msgHash["case"]["title"]} to caseblocks..."
58
58
 
59
- puts "Looking for customer..."
59
+ @logger.info "Looking for customer..."
60
60
  customer = find_or_create_customer(msgHash)
61
61
 
62
62
  msgHash["case"]["customer_ref"] = customer["customer_ref"]
63
63
 
64
- puts "Creating order in caseblocks..."
64
+ @logger.info "Creating order in caseblocks..."
65
65
  response = post("/case_blocks/tyre_shopper_orders", msgHash)
66
66
 
67
- puts "Done."
67
+ @logger.info "Done."
68
68
  @logger.info "Received #{response}"
69
69
  rescue RestClient::ExceptionWithResponse => ex
70
70
  if ex.response.nil?
@@ -84,7 +84,7 @@ module TyreshopperSqs2cb
84
84
  # if user was signed in then use member_id else use email
85
85
  if order_details["signed_in"]
86
86
 
87
- puts "Searching for customer on member_id #{order_details["member"]["member_id"]}..."
87
+ @logger.info "Searching for customer on member_id #{order_details["member"]["member_id"]}..."
88
88
 
89
89
  customer = {
90
90
  "case_type_id" => customer_case_type_id,
@@ -103,20 +103,20 @@ module TyreshopperSqs2cb
103
103
 
104
104
  cb_customer = find_customer(:member_id => order_details["member"]["member_id"])
105
105
  if cb_customer.nil?
106
- puts "Can't find customer by member_id, checking if the email is there..."
106
+ @logger.info "Can't find customer by member_id, checking if the email is there..."
107
107
 
108
108
  cb_customer = find_customer(:email => order_details["email"])
109
109
 
110
110
  if cb_customer
111
- puts "Found customer, need to update member_id and data"
111
+ @logger.info "Found customer, need to update member_id and data"
112
112
 
113
113
  cb_customer = ensure_taskslists_are_populated(cb_customer)
114
114
  put("/case_blocks/customer/#{cb_customer["_id"]}", {"customer" => customer})
115
115
 
116
116
  return cb_customer
117
117
  else
118
- puts "Unable to find customer"
119
- puts "Creating new customer from member details..."
118
+ @logger.info "Unable to find customer"
119
+ @logger.info "Creating new customer from member details..."
120
120
 
121
121
  result = post("/case_blocks/customer", customer)["case"]
122
122
  return result
@@ -125,15 +125,15 @@ module TyreshopperSqs2cb
125
125
  return cb_customer
126
126
  end
127
127
  else
128
- puts "Searching for customer on email #{order_details["email"]}..."
128
+ @logger.info "Searching for customer on email #{order_details["email"]}..."
129
129
 
130
130
  cb_customer = find_customer(:email => order_details["email"])
131
131
 
132
132
  if cb_customer
133
- puts "Found customer"
133
+ @logger.info "Found customer"
134
134
  return cb_customer
135
135
  else
136
- puts "Unable to find customer"
136
+ @logger.info "Unable to find customer"
137
137
 
138
138
  name_parts = parse_name(order_details["customer"])
139
139
 
@@ -152,7 +152,7 @@ module TyreshopperSqs2cb
152
152
 
153
153
  }
154
154
 
155
- puts "Creating new customer from order details..."
155
+ @logger.info "Creating new customer from order details..."
156
156
  return post("/case_blocks/customer", customer)["case"]
157
157
  end
158
158
  end
@@ -1,3 +1,3 @@
1
1
  module TyreshopperSqs2cb
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tyreshopper_sqs2cb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stewart McKee