lib/blurb.rb in blurb-0.3.2 vs lib/blurb.rb in blurb-0.4.0

- old
+ new

@@ -1,32 +1,26 @@ -require "oauth2" -require "rest-client" +require "blurb/account" +require "blurb/client" -require "blurb/version" -require "blurb/base_resource" +class Blurb + attr_accessor :client, :account -require "blurb/bid_recommendation" -require "blurb/campaign" -require "blurb/profile" -require "blurb/report" -require "blurb/snapshot" -require "blurb/suggested_keyword" -require "blurb/keyword" -require "blurb/ad_group" - -module Blurb - - def self.default_account - { - client_secret: self.client_secret, - client_id: self.client_id, - refresh_token: self.refresh_token, - profile_id: self.profile_id, - eu_env: self.eu_env - } + def initialize( + # Default to env variables + client_id: ENV["BLURB_CLIENT_ID"], + client_secret: ENV["BLURB_CLIENT_SECRET"], + refresh_token: ENV["BLURB_REFRESH_TOKEN"], + region: ENV["BLURB_REGION"], + profile_id: ENV["BLURB_PROFILE_ID"] # profile_id can be left nil + ) + @client = Client.new(client_id: client_id, client_secret: client_secret) + @account = Account.new(refresh_token: refresh_token, region: region, client: @client, profile_id: profile_id) end - class << self - attr_accessor :client_secret, :client_id, :refresh_token, :profile_id, :test_env, :eu_env + def profiles + @account.profiles end + def active_profile + @account.active_profile + end end