rubygarage / api_struct

API wrapper builder with response serialization
MIT License
234 stars 21 forks source link

New maintainable fork #21

Open kraft001 opened 1 year ago

kraft001 commented 1 year ago

Hi, RubyGarage team!

Many thanks for the amazing gem!

However, it hasn't been updated for quite a long time, so we had to fork and upgrade it to make compatible with new ruby versions: https://github.com/uploadcare/uploadcare-api_struct https://rubygems.org/gems/uploadcare-api_struct

Please, let me know if you decide to revive this gem and I'll prepare a PR to copy changes from the fork.

Thanks!

jaykilleen commented 1 year ago

Thanks for this @kraft001. I have switched mine over to your fork as I was running ruby 3.2.1 and getting an error something to do with dry-monads Transform / Transformer ... (should have copied it down) or something to that effect.

Once I forked... I had the error uninitialized constant ApiStruct (NameError) thrown which was resolved by simply adding require 'api_struct' to the top of my initializer.

Hopefully this helps someone else so thought I should share the experience.

_/config/initializers/apistruct.rb

require 'api_struct'

ApiStruct::Settings.configure do |config|
  config.endpoints = {
    api: {
      root: 'https://api.service.com/external/v1',
      headers: {
        'content-type': 'application/json',
        'Authorization': "Bearer #{ Rails.application.credentials.gospotcheck_api_token }"
      }
    }
  }
end