cherrypie-rails-sdk 0.2.2 → 0.2.6

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
  SHA256:
3
- metadata.gz: 852bae24086202eb021ffdcf15fcfc710eb2d045f27086fd4d4628c3aea409e0
4
- data.tar.gz: 52bf68d9350f8b42518f3020e2e3105c15e64e1cf5007bd25856930c8376ca35
3
+ metadata.gz: 3dbf37c31a4ee19ebc946c565c5393b116eab396744d6161002fff824073b7ef
4
+ data.tar.gz: 70f0b037240d413617b3bdc2499329a1c7a61f4477401a99d06b738be943d55f
5
5
  SHA512:
6
- metadata.gz: c2f3815c568f17d1a64910e4ab58c612c146c16b9b7cb416ee74644ca872628f7477107100238beee4cde04b793b5182e1f3db679f3e6e429fd8739be63a9088
7
- data.tar.gz: b6d830eabcf6536bb75ff2b158d71720b4dd91d9f8215ec7cccf9444179731e661c487855b9a28a048525c3c95970d457ef989415d5c67c8f7cfc51c83eba155
6
+ metadata.gz: ec05e31a58e44d9524f116fe8603c2d7919ef42ac765997885ecfbd30b49f186ddf8a737e92df4fce067fa8f286658a04d7ead87b894770770257f5b89c7eb44
7
+ data.tar.gz: 6f0d5b5d489a50a599a4862eb38c09c5c12a5d0a56dd8d266a764a3fe804d248381c9dfa841948af6273c1b5ac2e7b21c59b4a2034309123d631d03c74c0023d
data/README.md CHANGED
@@ -1,15 +1,13 @@
1
1
  # CherrypieRailsSdk
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/cherrypie_rails_sdk`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Cherrypie Rails SDK.
6
4
 
7
5
  ## Installation
8
6
 
9
7
  Add this line to your application's Gemfile:
10
8
 
11
9
  ```ruby
12
- gem 'cherrypie_rails_sdk'
10
+ gem 'cherrypie-rails-sdk', '~> 0.2.4'
13
11
  ```
14
12
 
15
13
  And then execute:
@@ -18,17 +16,33 @@ And then execute:
18
16
 
19
17
  Or install it yourself as:
20
18
 
21
- $ gem install cherrypie_rails_sdk
19
+ $ gem install cherrypie-rails-sdk
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- 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.
23
+ ```
24
+ # config/application.rb
25
+
26
+ require_relative "boot"
27
+
28
+ require "rails/all"
29
+ require 'cherrypie_rails_sdk'
30
+
31
+ Bundler.require(*Rails.groups)
32
+
33
+ module ExampleApp
34
+ class Application < Rails::Application
35
+ ...
36
+ config.middleware.use(CherrypieRailsSdk::Middleware, "<TOKEN>",
37
+ lambda{ |request| {
38
+ # request: ActionDispatch::Request
39
+ "entityKey"=> "1", "name"=> "RAILS"
40
+ } },
41
+ )
42
+ end
43
+ end
44
+ ```
30
45
 
31
- 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
46
 
33
47
  ## Contributing
34
48
 
@@ -5,7 +5,7 @@ require_relative "cherrypie_rails_sdk/version"
5
5
  module CherrypieRailsSdk
6
6
  class Error < StandardError; end
7
7
  class Middleware
8
- def initialize(app, api_key, api_url = "https://api.cherrypie.app", identity_function)
8
+ def initialize(app, api_key, identity_function, api_url: "http://api.cherrypie.app")
9
9
  @app = app
10
10
  @api_key = api_key
11
11
  @api_url = api_url
@@ -30,7 +30,10 @@ module CherrypieRailsSdk
30
30
  end
31
31
 
32
32
  def _build_response_payload(status, headers, response)
33
- body = response.respond_to?(:body)
33
+ body = nil
34
+ if response.respond_to?(:body)
35
+ body = response.body
36
+ end
34
37
  return {
35
38
  "headers"=> headers,
36
39
  "body"=> body,
@@ -73,9 +76,10 @@ module CherrypieRailsSdk
73
76
  }
74
77
  )
75
78
  request.body = payload
76
-
77
- response = http.request(request)
78
-
79
+ # Only log non-300 statuses.
80
+ if !(@status >= 300 && @status <= 399)
81
+ cherrypie_response = http.request(request)
82
+ end
79
83
  [@status, @headers, @response]
80
84
  end
81
85
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CherrypieRailsSdk
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.6"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cherrypie-rails-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Macro Computer Club
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-12 00:00:00.000000000 Z
11
+ date: 2021-08-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: CherryPie Rails SDK
14
14
  email: