Module: Mass

Defined in:
lib/mass-client.rb,
lib/base-line/job.rb,
lib/base-line/tag.rb,
lib/base-line/lead.rb,
lib/base-line/rule.rb,
lib/base-line/event.rb,
lib/base-line/source.rb,
lib/base-line/channel.rb,
lib/base-line/company.rb,
lib/base-line/profile.rb,
lib/base-line/request.rb,
lib/base-line/revenue.rb,
lib/base-line/industry.rb,
lib/base-line/location.rb,
lib/base-line/outreach.rb,
lib/base-line/data_type.rb,
lib/base-line/headcount.rb,
lib/base-line/enrichment.rb,
lib/base-line/inboxcheck.rb,
lib/base-line/source_type.rb,
lib/base-line/unsubscribe.rb,
lib/base-line/profile_type.rb,
lib/first-line/profile_api.rb,
lib/first-line/profile_mta.rb,
lib/first-line/profile_rpa.rb,
lib/base-line/outreach_type.rb,
lib/base-line/connectioncheck.rb,
lib/base-line/enrichment_type.rb

Overview

mass client configuration

Defined Under Namespace

Classes: Channel, Company, ConnectionCheck, DataType, Enrichment, EnrichmentType, Event, Headcount, InboxCheck, Industry, Job, Lead, Location, Outreach, OutreachType, Profile, ProfileAPI, ProfileMTA, ProfileRPA, ProfileType, Request, Revenue, Rule, Source, SourceType, Tag, Unsubscribe

Class Method Summary collapse

Class Method Details

.download_pathObject



82
83
84
# File 'lib/mass-client.rb', line 82

def self.download_path
    @@download_path
end

.js_pathObject



86
87
88
# File 'lib/mass-client.rb', line 86

def self.js_path
    @@js_path
end

.set(api_key:, subaccount: nil, api_url: 'https://massprospecting.com', api_port: 443, api_version: '1.0', backtrace: false, js_path: nil, download_path: []) ⇒ Object

set the MassProspecting API client

Parameters:

api_key: Mandatory. The API key of your MassProspecting account. subaccount: Optional. The name of the subaccount you want to work with. If you provide a subaccount, the SDK will call the master to get the URL and port of the subaccount. Default is nil. api_url: Optional. The URL of the MassProspecting API. Default is ‘massprospecting.com’. api_port: Optional. The port of the MassProspecting API. Default is 443. api_version: Optional. The version of the MassProspecting API. Default is ‘1.0’. backtrace: Optional. If true, the backtrace of the exceptions will be returned by the access points. If false, only an error description is returned. Default is false. js_path: Optional. The path to the JavaScript file to be used by the SDK. Default is nil. download_path: Optional. The path to the download folder(s) to be used by the SDK. Default is [].



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/mass-client.rb', line 29

def self.set(
    api_key: ,
    subaccount: nil,
    api_url: 'https://massprospecting.com', 
    api_port: 443,
    api_version: '1.0',
    backtrace: false,
    js_path: nil, 
    download_path: []
)
    # call the master to get the URL and port of the subaccount.
    BlackStack::API.set_client(
        api_key: api_key,
        api_url: api_url,
        api_port: api_port,
        api_version: api_version,
        backtrace: backtrace
    )
    
    if subaccount
        params = { 'name' => subaccount }
        ret = BlackStack::API.post(
            endpoint: "resolve/get",
            params: params
        )

        raise "Error initializing client: #{ret['status']}" if ret['status'] != 'success'
        
        # call the master to get the URL and port of the subaccount.
        BlackStack::API.set_client(
            api_key: ret['api_key'],
            api_url: ret['url'],
            api_port: ret['port'],
            api_version: api_version,
            backtrace: backtrace
        )
    end

    # validate: download_path must be a string or an arrow of strings
    if download_path.is_a?(String)
        raise ArgumentError.new("The parameter 'download_path' must be a string or an array of strings.") if download_path.to_s.empty?
    elsif download_path.is_a?(Array)
        download_path.each { |p|
            raise ArgumentError.new("The parameter 'download_path' must be a string or an array of strings.") if p.to_s.empty?
        }
    else
        raise ArgumentError.new("The parameter 'download_path' must be a string or an array of strings.")
    end

    @@js_path = js_path
    @@download_path = download_path
end