broadstreet 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3ed338038c8319c4491ee57dbe1cdca6c65b8f3c
4
+ data.tar.gz: 24def22fd30cfa36ecbba67f39b7b79497e3e3e1
5
+ SHA512:
6
+ metadata.gz: d07b75367caff967dcc4f8a9331b458c1594bf8b4d46e4640c44665c383074105c84511c4b7de4d9c2bab05a925094e580c1941983a47127af673ac6491cd42f
7
+ data.tar.gz: 88062d795602117df6fe9f5a0a613dbfc1402d9304f800e350764ae9976d6e1928e011d82a97d2f598662291f48bced56ab384b8a0f5d2051602e4a3019743ad
@@ -0,0 +1,52 @@
1
+ module Broadstreet
2
+
3
+ module AdvertiserMethods
4
+
5
+ # Create a new advertiser
6
+ #
7
+ # @param [Fixnum] network_id: The ID of the network for the new advertiser
8
+ # @param [Hash] params: The detail to create the network with
9
+ # @option params [String] name: The name for the advertiser
10
+ # @return [Hash] the detail of the new advertiser
11
+ def create_advertiser(network_id, params)
12
+ request(:post, "api/1/networks/#{network_id}/advertisers", params).advertiser
13
+ end
14
+
15
+ # Update the detail of a given advertiser
16
+ #
17
+ # @param [Fixnum] advertiser_id: The ID of the advertiser to update
18
+ # @param [Hash] params: The detail to update the network with
19
+ # @option params [String] name: The name for the advertiser
20
+ # @return [Hash] the detail of the updated advertiser
21
+ def update_advertiser(advertiser_id, params)
22
+ request(:put, "api/1/advertisers/#{advertiser_id}", params).advertiser
23
+ end
24
+
25
+ # Delete an advertiser
26
+ #
27
+ # @param [Fixnum] advertiser_id: the ID of the advertiser to delete
28
+ # @return nil
29
+ def delete_advertiser(advertiser_id)
30
+ request :delete, "api/1/advertisers/#{advertiser_id}"
31
+ nil
32
+ end
33
+
34
+ # Get the detail for a given advertiser
35
+ #
36
+ # @param [Fixnum] advertiser_id: The ID of the advertiser to lookup
37
+ # @return [Hash] the detail hash for the advertiser
38
+ def get_advertiser(advertiser_id)
39
+ request(:get, "api/1/advertisers/#{advertiser_id}").advertiser
40
+ end
41
+
42
+ # List advertisers for a given network
43
+ #
44
+ # @param [Fixnum] network_id: The ID of the network to retrieve advertisers for
45
+ # @return [Array<Hash>] an array of detail hashes for the advertisers
46
+ def list_advertisers(network_id)
47
+ request(:get, "api/1/advertisers", network_id: network_id).advertisers
48
+ end
49
+
50
+ end
51
+
52
+ end
@@ -0,0 +1,52 @@
1
+ module Broadstreet
2
+
3
+ module CampaignMethods
4
+
5
+ # List campaigns for a given advertiser
6
+ #
7
+ # @param [Fixnum] advertiser_id: The ID of the advertiser to retrieve campaigns for
8
+ # @return [Array<Hash>] details of the campaigns for the advertiser
9
+ def list_campaigns(advertiser_id)
10
+ request(:get, "api/1/advertiers/#{advertiser_id}/campaigns").campaigns
11
+ end
12
+
13
+ # Get the data for a given campaign
14
+ #
15
+ # @param [Fixnum] campaign_id: The ID of the campaign to retrieve
16
+ # @return [Hash] the detail for the given campaign
17
+ def get_campaign(campaign_id)
18
+ request(:get, "api/1/campaigns/#{campaign_id}").campaign
19
+ end
20
+
21
+ # Delete a given campaign
22
+ #
23
+ # @param [Fixnum] campaign_id: The ID of the campaign to delete
24
+ # @return nil
25
+ def delete_campaign(campaign_id)
26
+ request :delete, "api/1/campaigns/#{campaign_id}"
27
+ nil
28
+ end
29
+
30
+ # Update a campaign
31
+ #
32
+ # @param [Fixnum] campaign_id: The ID of the campaign to update
33
+ # @param [Hash] params: The data to update the campaign with
34
+ # @option params [String] name: The name of the campaign
35
+ # @return [Hash] the detail of the updated campaign
36
+ def update_campaign(campaign_id, params)
37
+ request(:put, "api/1/campaigns/#{camapign_id}", params).campaign
38
+ end
39
+
40
+ # Create a campaign
41
+ #
42
+ # @param [Fixnum] advertiser_id: The ID of the advertiser to create the campaign under
43
+ # @param [Hash] params: The data to create the campaign with
44
+ # @option params [String] name: The name of the campaign
45
+ # @return [Hash] the detail of the new campaign
46
+ def create_campaign(advertiser_id, params)
47
+ request(:post, "api/1/advertisers/#{advertiser_id}/campaigns", params).campaign
48
+ end
49
+
50
+ end
51
+
52
+ end
@@ -0,0 +1,41 @@
1
+ require 'broadstreet/advertiser_methods'
2
+ require 'broadstreet/campaign_methods'
3
+ require 'broadstreet/network_methods'
4
+ require 'broadstreet/user_methods'
5
+ require 'broadstreet/zone_methods'
6
+ require 'hashie'
7
+ require 'faraday'
8
+ require 'json'
9
+
10
+ module Broadstreet
11
+
12
+ class Client
13
+
14
+ include AdvertiserMethods
15
+ include CampaignMethods
16
+ include NetworkMethods
17
+ include UserMethods
18
+ include ZoneMethods
19
+
20
+ # Instantiate a new client
21
+ #
22
+ # @param [String] access_token: Broadstreet Access Token (optional)
23
+ def initialize(access_token = nil)
24
+ @access_token = access_token
25
+ end
26
+
27
+ private
28
+
29
+ def request(method, path, params = {})
30
+ params[:access_token] = @access_token
31
+ response = connection.send method, path, params
32
+ Hashie::Mash.new JSON.parse response.body
33
+ end
34
+
35
+ def connection
36
+ @connection ||= Faraday.new(:url => 'https://api.broadstreetads.com')
37
+ end
38
+
39
+ end
40
+
41
+ end
@@ -0,0 +1,40 @@
1
+ module Broadstreet
2
+
3
+ module NetworkMethods
4
+
5
+ # List accessible networks
6
+ #
7
+ # @return [Array<Hash>] the data for the networks
8
+ def list_networks
9
+ request(:get, 'api/1/networks').networks
10
+ end
11
+
12
+ # Get a particular network
13
+ #
14
+ # @param [Fixnum] network_id: The ID of the network to retrieve
15
+ # @return [Hash] the network detail
16
+ def get_network(network_id)
17
+ request(:get, "api/1/networks/#{network_id}").network
18
+ end
19
+
20
+ # Update the data for a particular network
21
+ #
22
+ # @param [Fixnum] network_id: The ID of the network to update
23
+ # @option params [String] :name The name of the network
24
+ # @return [Hash] the updated network detail
25
+ def update_network(network_id, params)
26
+ request(:put, "api/1/networks/#{network_id}", params).network
27
+ end
28
+
29
+ # Create a new network and make the current user a network_admin
30
+ #
31
+ # @param [Hash] params: a hash of the data for the network
32
+ # @option params [String] :name The name of the network
33
+ # @return [Hash] the detail of the created network
34
+ def create_network(params)
35
+ request(:post, 'api/1/networks', params).network
36
+ end
37
+
38
+ end
39
+
40
+ end
@@ -0,0 +1,28 @@
1
+ module Broadstreet
2
+
3
+ module UserMethods
4
+
5
+ # Create a new broadstreet user
6
+ #
7
+ # @param [Hash] params: Detail for the user
8
+ # @option params [String] name: A name for the user (optional)
9
+ # @option params [String] email: An email address
10
+ # @option params [String] password: A password
11
+ # @return [Hash] user detail
12
+ def create_user(params)
13
+ request(:post, 'api/0/users', params).user
14
+ end
15
+
16
+ # Add an email address to the broadstreet newsletter
17
+ #
18
+ # param [Hash] params: Detail for the email address
19
+ # @option params [String] email: The email address to add
20
+ # @return nil
21
+ def create_newsletter_subscription(params)
22
+ request(:post, 'api/0/newsletter', params)
23
+ nil
24
+ end
25
+
26
+ end
27
+
28
+ end
@@ -0,0 +1,5 @@
1
+ module Broadstreet
2
+
3
+ VERSION = '0.0.1'
4
+
5
+ end
@@ -0,0 +1,56 @@
1
+ module Broadstreet
2
+
3
+ module ZoneMethods
4
+
5
+ # Create a new zone
6
+ #
7
+ # @param [Fixnum] network_id: the id of the network to create the zone on
8
+ # @param [Hash] params: a hash of the data for the zone
9
+ # @option params [String] :name The name of the zone
10
+ # @option params [Boolean] :self_server Whether the zone is self serve
11
+ # @option params [String] :pricing_callback_url Callback for pricing on self-serve zones
12
+ # @return [Hash] the zone detail
13
+ def create_zone(network_id, params)
14
+ request(:post, "api/1/networks/#{network_id}/zones", params).zone
15
+ end
16
+
17
+ # Get a zone
18
+ #
19
+ # @param [Fixnum] zone_id: The ID of the zone to retrieve
20
+ # @return [Hash] the zone detail
21
+ def get_zone(zone_id)
22
+ request(:get, "api/1/zones/#{zone_id}").zone
23
+ end
24
+
25
+ # Delete a zone
26
+ #
27
+ # @param [Fixnum] zone_id: THe ID of the zone to delete
28
+ # @return nil
29
+ def delete_zone(zone_id)
30
+ request :delete, "api/1/zones/#{zone_id}"
31
+ nil
32
+ end
33
+
34
+ # List zones for a given network
35
+ #
36
+ # @param [Fixnum] network_id: The ID of the network to retrieve zones for
37
+ # @return [Array<Hash>] the data for the zones on the specified network
38
+ def list_zones(network_id)
39
+ request(:get, 'api/1/zones', network_id: network_id).zones
40
+ end
41
+
42
+ # Update a zone
43
+ #
44
+ # @param [Fixnum] zone_id: The ID of the zone to update
45
+ # @param [Hash] params: a hash of the data for the zone
46
+ # @option params [String] :name The name of the zone
47
+ # @option params [Boolean] :self_server Whether the zone is self serve
48
+ # @option params [String] :pricing_callback_url Callback for pricing on self-serve zones
49
+ # @return [Hash] the updated zone detail
50
+ def update_zone(zone_id, params)
51
+ request(:put, "api/1/zones/#{id}", params).zone
52
+ end
53
+
54
+ end
55
+
56
+ end
@@ -0,0 +1,7 @@
1
+ $LOAD_PATH << File.dirname(__FILE__)
2
+
3
+ module Broadstreet
4
+
5
+ autoload :Client, 'broadstreet/client'
6
+
7
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: broadstreet
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - John Crepezzi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: hashie
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email: john@broadstreetads.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - lib/broadstreet.rb
48
+ - lib/broadstreet/advertiser_methods.rb
49
+ - lib/broadstreet/campaign_methods.rb
50
+ - lib/broadstreet/client.rb
51
+ - lib/broadstreet/network_methods.rb
52
+ - lib/broadstreet/user_methods.rb
53
+ - lib/broadstreet/version.rb
54
+ - lib/broadstreet/zone_methods.rb
55
+ homepage: https://github.com/broadstreetads/broadstreet-ruby
56
+ licenses:
57
+ - MIT
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 2.2.0
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: Broadstreet API Wrapper
79
+ test_files: []