e_plat 0.2.3 → 0.3.0
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 +4 -5
- data/lib/current.rb +7 -0
- data/lib/e_plat/errors/missing_session_error.rb +1 -1
- data/lib/e_plat/resource/base.rb +2 -4
- data/lib/e_plat/resource/shop.rb +1 -1
- data/lib/e_plat/session.rb +10 -13
- data/lib/e_plat/types.rb +1 -1
- data/lib/e_plat/version.rb +1 -1
- data/lib/e_plat.rb +0 -1
- metadata +3 -17
- data/lib/e_plat/session_state.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e070573b55b7ee4badc6e492bc04bf13f0edc534f937eaae8b0bafe5f78beea
|
4
|
+
data.tar.gz: e3c7a0b699e11057b08659bdcbe1c9c993d575b8e0ba7988f3f7cdd12c46e7ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f80544f6fdf55208b4b8640631c0d39bc3c21b21dc8b1ee4bad3ebd3d56e343c3bf7164be655db8510bb62fc0cb5f3d8423b32e4f68b1ed47714ae02b312b373
|
7
|
+
data.tar.gz: 0c86da79e297bffad3c1348e92a2b69129298b82818beb4da1352610f1ff7efc0ac30fbe5d9df8a811a7ef7cef2fc989007b11946cbdc9bae2a1751f0452e839
|
data/README.md
CHANGED
@@ -50,9 +50,7 @@ https://dev.to/doctolib/release-a-new-gem-version-je0
|
|
50
50
|
|
51
51
|
## Usage
|
52
52
|
|
53
|
-
1.
|
54
|
-
|
55
|
-
2. To make requests, first initialize a session like so:
|
53
|
+
1. To make requests, first initialize a session like so:
|
56
54
|
```ruby
|
57
55
|
EPlat::Session.new(
|
58
56
|
platform: :shopify,
|
@@ -62,12 +60,12 @@ EPlat::Session.new(
|
|
62
60
|
)
|
63
61
|
```
|
64
62
|
|
65
|
-
|
63
|
+
2. You can then make requests to the platform via a singleton call on the Resource class:
|
66
64
|
```ruby
|
67
65
|
EPlat::Product.find(id: 123)
|
68
66
|
```
|
69
67
|
|
70
|
-
|
68
|
+
3. Which will return an instance of:
|
71
69
|
```ruby
|
72
70
|
EPlat::Product
|
73
71
|
```
|
@@ -91,6 +89,7 @@ EPlat::Product
|
|
91
89
|
</li>
|
92
90
|
<li>
|
93
91
|
The EPlat alias interface is just a set of dynamically created getter/setter/predicate methods with types that control the native attributes of the resource.
|
92
|
+
You can check if an attribute has been mapped by calling `@resource.mapped? "attribute_name"`
|
94
93
|
</li>
|
95
94
|
</ul>
|
96
95
|
</ol>
|
data/lib/current.rb
ADDED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
module EPlat
|
3
3
|
class MissingSessionError < StandardError
|
4
|
-
def initialize(msg="Missing session state, did you
|
4
|
+
def initialize(msg="Missing session state, did you set EPlat::Session")
|
5
5
|
super
|
6
6
|
end
|
7
7
|
end
|
data/lib/e_plat/resource/base.rb
CHANGED
@@ -4,12 +4,11 @@ module EPlat
|
|
4
4
|
class Base < ActiveResource::Base
|
5
5
|
|
6
6
|
class << self
|
7
|
-
include Dry::Effects.State(:e_plat_session)
|
8
7
|
include Concerns::OverwriteRequestMethods
|
9
8
|
threadsafe_attribute :client, :mapping, :include_root_in_json, :include_format_in_path
|
10
9
|
|
11
10
|
def initialize_singleton!
|
12
|
-
self.client = e_plat_session
|
11
|
+
self.client = Current.e_plat_session
|
13
12
|
|
14
13
|
self.site = client.base_url
|
15
14
|
self.prefix = client.url_prefix
|
@@ -37,13 +36,12 @@ module EPlat
|
|
37
36
|
end
|
38
37
|
|
39
38
|
|
40
|
-
include Dry::Effects.State(:e_plat_session)
|
41
39
|
include Concerns::Aliases, Concerns::OverwriteInstanceMethods
|
42
40
|
|
43
41
|
attr_accessor :client, :mapping, :mapped_attributes
|
44
42
|
|
45
43
|
def initialize(attributes = {}, persisted = false)
|
46
|
-
self.client = e_plat_session
|
44
|
+
self.client = Current.e_plat_session
|
47
45
|
site = client.base_url
|
48
46
|
self.mapping = mapping_instance
|
49
47
|
ActiveResource::Base.include_root_in_json = client.shopify? && top_level_resource?
|
data/lib/e_plat/resource/shop.rb
CHANGED
data/lib/e_plat/session.rb
CHANGED
@@ -1,20 +1,17 @@
|
|
1
1
|
|
2
2
|
module EPlat
|
3
3
|
class Session
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
e_plat_session.
|
11
|
-
e_plat_session.
|
12
|
-
e_plat_session.api_token = api_token
|
13
|
-
e_plat_session.store_hash = store_hash
|
4
|
+
#the session is an instance of EPlat::Client made available via Rails Current::Attributes
|
5
|
+
|
6
|
+
def initialize(platform:, store_url:, api_token:, store_hash: nil)
|
7
|
+
Current.e_plat_session = EPlat::Client.new
|
8
|
+
Current.e_plat_session.platform = platform
|
9
|
+
Current.e_plat_session.store_url = store_url
|
10
|
+
Current.e_plat_session.api_token = api_token
|
11
|
+
Current.e_plat_session.store_hash = store_hash
|
14
12
|
|
15
|
-
e_plat_session.send(:get_api_version) if e_plat_session.active?
|
16
|
-
|
13
|
+
Current.e_plat_session.send(:get_api_version) if Current.e_plat_session.active?
|
14
|
+
end
|
17
15
|
|
18
|
-
|
19
16
|
end
|
20
17
|
end
|
data/lib/e_plat/types.rb
CHANGED
data/lib/e_plat/version.rb
CHANGED
data/lib/e_plat.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: e_plat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- oliwoodsuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,20 +122,6 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: dry-effects
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - '='
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0.4'
|
132
|
-
type: :runtime
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - '='
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0.4'
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: webmock
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -191,6 +177,7 @@ files:
|
|
191
177
|
- app/assets/config/e_plat_manifest.js
|
192
178
|
- config/routes.rb
|
193
179
|
- lib/active_resource/schema.rb
|
180
|
+
- lib/current.rb
|
194
181
|
- lib/e_plat.rb
|
195
182
|
- lib/e_plat/client.rb
|
196
183
|
- lib/e_plat/client/default_request_args.rb
|
@@ -225,7 +212,6 @@ files:
|
|
225
212
|
- lib/e_plat/resource/product/variant.rb
|
226
213
|
- lib/e_plat/resource/shop.rb
|
227
214
|
- lib/e_plat/session.rb
|
228
|
-
- lib/e_plat/session_state.rb
|
229
215
|
- lib/e_plat/type_coercer.rb
|
230
216
|
- lib/e_plat/types.rb
|
231
217
|
- lib/e_plat/version.rb
|
data/lib/e_plat/session_state.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
|
2
|
-
module EPlat
|
3
|
-
module SessionState
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
include Dry::Effects::Handler.State(:e_plat_session)
|
6
|
-
|
7
|
-
included do
|
8
|
-
around_action :set_e_plat_session
|
9
|
-
end
|
10
|
-
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def set_e_plat_session
|
15
|
-
with_e_plat_session(e_plat_session) { yield }
|
16
|
-
end
|
17
|
-
|
18
|
-
def e_plat_session
|
19
|
-
# create empty client.
|
20
|
-
# Will be populated later by EPlat::Session.new(..) if needed
|
21
|
-
EPlat::Client.new()
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|