Class: CirroIO::Client::Base
- Inherits:
-
JsonApiClient::Resource
- Object
- JsonApiClient::Resource
- CirroIO::Client::Base
- Defined in:
- lib/cirro_io/client/base.rb
Direct Known Subclasses
AppUser, AppWorker, Gig, GigInvitation, GigResult, GigTask, GigTimeActivity, NotificationsBroadcast, NotificationsTemplate, NotificationsTopic, Payout, WorkerFilter
Class Method Summary collapse
- .custom_connection ⇒ Object
- .custom_post(endpoint, payload) ⇒ Object
-
.site=(url) ⇒ Object
HACK: github.com/JsonApiClient/json_api_client/issues/215 Used for initialization as well.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Base
constructor
HACK: github.com/JsonApiClient/json_api_client/issues/390 waiting for json_api_client to release a new version with the fix github.com/JsonApiClient/json_api_client/pull/398 rubocop:disable all.
Constructor Details
#initialize(params = {}) ⇒ Base
HACK: github.com/JsonApiClient/json_api_client/issues/390 waiting for json_api_client to release a new version with the fix github.com/JsonApiClient/json_api_client/pull/398 rubocop:disable all
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/cirro_io/client/base.rb', line 36 def initialize(params = {}) params = params.with_indifferent_access @persisted = nil @destroyed = nil self.links = self.class.linker.new(params.delete(:links) || {}) self.relationships = self.class.relationship_linker.new(self.class, params.delete(:relationships) || {}) self.attributes = self.class.default_attributes.merge params.except(*self.class.prefix_params) self.forget_change!(:type) self.__belongs_to_params = params.slice(*self.class.prefix_params) setup_default_properties self.request_params = self.class.request_params_class.new(self.class) end |
Class Method Details
.custom_connection ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/cirro_io/client/base.rb', line 23 def self.custom_connection Faraday.new(url: "#{CirroIO::Client.configuration.site}/#{CirroIO::Client.configuration.api_version}") do |conn| conn.request :json conn.response :json conn.use CirroIO::Client::JwtAuthentication conn.use JsonApiClient::Middleware::Status, {} end end |
.custom_post(endpoint, payload) ⇒ Object
19 20 21 |
# File 'lib/cirro_io/client/base.rb', line 19 def self.custom_post(endpoint, payload) custom_connection.post(endpoint, payload.to_json) end |
.site=(url) ⇒ Object
HACK: github.com/JsonApiClient/json_api_client/issues/215 Used for initialization as well
9 10 11 12 13 14 15 16 17 |
# File 'lib/cirro_io/client/base.rb', line 9 def self.site=(url) super.tap do connection true do |connection| connection.use JwtAuthentication connection.use Faraday::Response::Logger # connection.use ResponseDebuggingMiddleware # for debugging or while adding new specs end end end |