Add this line to your application's Gemfile:
gem 'loggi', github: 'petlove/loggi-ruby'
And then execute:
$ bundle
You should use the model Loggi::Crendetial
to generate your api_key
.
credential = Loggi::Credential.new(email: email, password: password)
credential.authenticate!
credential.api_key
# => 14651f0f-8888-4100-9ab7-cf4b2dffb31e
You should configure your credential to have access to authenticated resources with this code:
Loggi::Configuration.configure!(Loggi::Credential.new(
email: ENV['LOGGI_API_EMAIL'],
api_key: ENV['LOGGI_API_KEY']
))
If you want to request to authenticate all times that you configure your application, you may use this code:
Loggi::Configuration.configure!(Loggi::Credential.new(
email: ENV['LOGGI_API_EMAIL'],
password: ENV['LOGGI_API_PASSWORD']
))
You should use the model Loggi::Shop
to list your shops.
Loggi::Shop.list
You should use the model Loggi::Order
to create your orders.
Loggi::Order.create!(
shop: Loggi::Shop.new,
pickups: [Loggi::Pickup.new],
packages: [Loggi::Package.new]
)
The options could be a Hash like this:
Loggi::Order.create!(
shop: {
name: 'Coelho Burguer',
pk: 3987
},
pickups: [
{
address: {
lat: -23.5516433,
lng: -46.6516703,
formatted_address: 'Av. Dr. Cardoso de Melo, 1155 - Vila Olimpia, São Paulo - SP, 04548-004, Brazil',
complement: '8o andar'
},
instructions: 'Pegar no balcão'
}
],
packages: [
{
pickup_index: 0,
recipient: {
name: 'Client XYZ',
phone: '1199678890'
},
address: {
lat: -23.5516433,
lng: -46.6516703,
formatted_address: 'R. Sansão Alves dos Santos, 138, Cidade Monções São Paulo - SP Brasil',
complement: '8o andar'
},
charge: {
value: 10,
method: 2,
change: 5
},
dimensions: {
width: 10,
height: 11,
length: 12
},
instructions: 'Deixar na porta'
}
]
)
You could use this code to get the history about the package:
LoggiPackage.new(pk: 10).history!
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.
Bug reports and pull requests are welcome!
AuthenticationList shops- List packages
Package's history- Package's status
Create an order- Estimate an order by geolocation
- Estimate an order by package and pickups
- Remake an order
- Tracking an order
- Edit an order
Config Travis as the CI- Config fields requested in each service by Loggi::Configuration
The gem is available as open source under the terms of the MIT License.