-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Customer Management service: get accounts info
- Loading branch information
Showing
57 changed files
with
1,463 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# -*- encoding : utf-8 -*- | ||
|
||
module BingAdsApi | ||
|
||
# Public : Define an account info | ||
# | ||
# Author:: [email protected] | ||
# | ||
# Examples | ||
# campaign = BingAdsApi::AccountInfo.new( | ||
# :account_life_cycle_status => BingAdsApi::AccountsInfo::DRAFT | ||
# :name => "Account Name", | ||
# :number => 1234567, | ||
# :pause_reason => "1") | ||
# # => <BingAdsApi::AccountInfo> | ||
class AccountInfo < BingAdsApi::DataObject | ||
include BingAdsApi::AccountLifeCycleStatuses | ||
|
||
attr_accessor :id, :account_life_cycle_status, :name, :number, :pause_reason | ||
|
||
# Public:: Returns true if the account is in status active | ||
# | ||
# Author:: [email protected] | ||
# | ||
# Returns:: boolean | ||
def active? | ||
return account_life_cycle_status == ACTIVE | ||
end | ||
|
||
|
||
# Public:: Returns true if the account is in status draft | ||
# | ||
# Author:: [email protected] | ||
# | ||
# Returns:: boolean | ||
def draft? | ||
return account_life_cycle_status == DRAFT | ||
end | ||
|
||
|
||
# Public:: Returns true if the account is in status inactive | ||
# | ||
# Author:: [email protected] | ||
# | ||
# Returns:: boolean | ||
def inactive? | ||
return account_life_cycle_status == INACTIVE | ||
end | ||
|
||
|
||
# Public:: Returns true if the account is in status pause | ||
# | ||
# Author:: [email protected] | ||
# | ||
# Returns:: boolean | ||
def pause? | ||
return account_life_cycle_status == PAUSE | ||
end | ||
|
||
|
||
# Public:: Returns true if the account is in status pending | ||
# | ||
# Author:: [email protected] | ||
# | ||
# Returns:: boolean | ||
def pending? | ||
return account_life_cycle_status == PENDING | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ class Service | |
# Default logger for services | ||
LOGGER = Logger.new(STDOUT) | ||
|
||
|
||
# Public : Constructor | ||
# | ||
# Author:: [email protected] | ||
|
@@ -62,7 +63,8 @@ def initialize(options={}) | |
self.client_proxy = BingAdsApi::ClientProxy.new(clientProxySettings) | ||
|
||
end | ||
|
||
|
||
|
||
# Public : This is a utility wrapper for calling services into the | ||
# +ClientProxy+. This methods handle all the +Savon::Client+ Exceptions | ||
# and returns a Hash with the call response | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# -*- encoding : utf-8 -*- | ||
module BingAdsApi | ||
|
||
|
||
# Public : This class represents the Customer Management Services | ||
# defined in the Bing Ads API, to manage customer accounts | ||
# | ||
# Author:: [email protected] | ||
# | ||
# Examples | ||
# options = { | ||
# :environment => :sandbox, | ||
# :username => "username", | ||
# :password => "pass", | ||
# :developer_token => "SOME_TOKEN", | ||
# :customer_id => "1234567", | ||
# :account_id => "9876543" } | ||
# service = BingAdsApi::CustomerManagement.new(options) | ||
class CustomerManagement < BingAdsApi::Service | ||
|
||
|
||
# Public : Constructor | ||
# | ||
# Author:: [email protected] | ||
# | ||
# options - Hash with the parameters for the client proxy and the environment | ||
# | ||
# Examples | ||
# options = { | ||
# :environment => :sandbox, | ||
# :username => "username", | ||
# :password => "password", | ||
# :developer_token => "DEV_TOKEN", | ||
# :customer_id => "123456", | ||
# :account_id => "654321" | ||
# } | ||
# service = BingAdsApi::CustomerManagement.new(options) | ||
def initialize(options={}) | ||
super(options) | ||
end | ||
|
||
|
||
######################### | ||
## Operations Wrappers ## | ||
######################### | ||
|
||
# Public : Gets a list of objects that contains account identification information, | ||
# for example the name and identifier of the account, for the specified customer. | ||
# | ||
# Author:: [email protected] | ||
# | ||
# === Parameters | ||
# +customer_id+ - identifier for the customer who owns the accounts. If nil, then the authentication customer id is used | ||
# +only_parent_accounts+ - boolean to determine whether to return only the accounts that belong to the customer or to also | ||
# return the accounts that the customer manages for other customers. Default false | ||
# | ||
# === Examples | ||
# customer_management_service.get_accounts_info | ||
# # => Array[BingAdsApi::AccountsInfo] | ||
# | ||
# Returns:: Array of BingAdsApi::AccountsInfo | ||
# | ||
# Raises:: exception | ||
def get_accounts_info(customer_id=nil, only_parent_accounts=false) | ||
response = call(:get_accounts_info, | ||
{customer_id: customer_id || self.client_proxy.customer_id, | ||
only_parent_accounts: only_parent_accounts.to_s}) | ||
response_hash = get_response_hash(response, __method__) | ||
accounts = response_hash[:accounts_info][:account_info].map do |account_hash| | ||
BingAdsApi::AccountInfo.new(account_hash) | ||
end | ||
return accounts | ||
end | ||
|
||
|
||
private | ||
def get_service_name | ||
"customer_management" | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,10 +86,27 @@ def object_to_hash(object, keys_case=:underscore) | |
end | ||
|
||
|
||
# Public:: Normalize the keys of a hash with the case specified | ||
# | ||
# Author:: [email protected] | ||
# | ||
# === Parameters | ||
# * +hash+ - Hash to be normalized | ||
# * +keys_case+ - :underscore or :camelcase | ||
# | ||
# === Examples | ||
# normalize_hash_keys({:some_key => value1}, :camelcase) | ||
# # => {"SomeKey" => value1} | ||
# | ||
# normalize_hash_keys({:some_key => value1}, :underscore) | ||
# # => {"some_key" => value1} | ||
# | ||
# Returns:: Hash | ||
def normalize_hash_keys(hash, keys_case) | ||
return hash.inject({}) { |h, (k, v)| h[get_attribute_key(k, keys_case)] = object_to_hash(v, keys_case); h } | ||
end | ||
|
||
|
||
# Internal : Helper method to determinate the key name in the hash for the SOAP request | ||
# | ||
# Author:: [email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
module BingAdsApi | ||
|
||
# Gem Version | ||
VERSION = "0.1.0" | ||
VERSION = "0.2.0" | ||
end |
Oops, something went wrong.