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 +4 -4
- data/README.md +25 -11
- data/lib/cherrypie_rails_sdk.rb +9 -5
- data/lib/cherrypie_rails_sdk/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3dbf37c31a4ee19ebc946c565c5393b116eab396744d6161002fff824073b7ef
|
4
|
+
data.tar.gz: 70f0b037240d413617b3bdc2499329a1c7a61f4477401a99d06b738be943d55f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec05e31a58e44d9524f116fe8603c2d7919ef42ac765997885ecfbd30b49f186ddf8a737e92df4fce067fa8f286658a04d7ead87b894770770257f5b89c7eb44
|
7
|
+
data.tar.gz: 6f0d5b5d489a50a599a4862eb38c09c5c12a5d0a56dd8d266a764a3fe804d248381c9dfa841948af6273c1b5ac2e7b21c59b4a2034309123d631d03c74c0023d
|
data/README.md
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
# CherrypieRailsSdk
|
2
2
|
|
3
|
-
|
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 '
|
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
|
19
|
+
$ gem install cherrypie-rails-sdk
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
|
data/lib/cherrypie_rails_sdk.rb
CHANGED
@@ -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
|
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 =
|
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
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2021-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: CherryPie Rails SDK
|
14
14
|
email:
|