Open jNicker opened 6 years ago
Too much time has gone from this question but maybe my answer will be useful in the future. How I use the gem:
require "beeswaxapi"
BeeswaxAPI::App.configure do |config|
config.auth_strategy = 'cookies'
config.cookie_file = './beeswax-cookie'
config.base_uri = 'https://demosbx.api.beeswax.com/rest'
config.user_name = 'email@address.com'
config.password = 'the_pass_to_beeswax_account'
end
credential = {
email: 'email@address.com',
password: "the_pass_to_beeswax_account",
keep_logged_in: true
}
puts BeeswaxAPI::Authenticate.create(body_params: credential)
puts BeeswaxAPI::Campaign.retrieve(params:{ campaign_id: 204})
Pardon my horrible markdown skills.
Couple of things shen using cookie auth:
If the file referenced does not exist it should be created. I have been able to get around this with:
but it would be nice if this was automatic
cookie_file is not flushed to disk since there is no wrapping around calling an api endpoint, it seems that a user first needs to call the authenticate endpoint first.
BeeswaxAPI::Authenticate.create(body_params: {email: 'foo@bar.com', password: 'XXXX' })
You would think that on success, that the request would then write the correct cookies into the cookies file, but this is not the case. Typhoeus does not flush them to disk, and does not use them on the subsequent calls. Maybe a change is needed to BeeswaxAPI::RequestIf I am incorrect in any of my assumptions above or am not using the gem as designed, then I would love some direction about where Im going wrong.