All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.microsoft.bingads.v13.bulk.entities.BulkCallAdExtension Maven / Gradle / Ivy

Go to download

The Bing Ads Java SDK is a library improving developer experience when working with the Bing Ads services by providing high-level access to features such as Bulk API, OAuth Authorization and SOAP API.

There is a newer version: 13.0.22.1
Show newest version
package com.microsoft.bingads.v13.bulk.entities;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.microsoft.bingads.internal.functionalinterfaces.BiConsumer;
import com.microsoft.bingads.internal.functionalinterfaces.Function;
import com.microsoft.bingads.v13.bulk.BulkFileReader;
import com.microsoft.bingads.v13.bulk.BulkFileWriter;
import com.microsoft.bingads.v13.bulk.BulkOperation;
import com.microsoft.bingads.v13.bulk.BulkServiceManager;
import com.microsoft.bingads.v13.campaignmanagement.CallAdExtension;
import com.microsoft.bingads.v13.internal.bulk.BulkMapping;
import com.microsoft.bingads.v13.internal.bulk.MappingHelpers;
import com.microsoft.bingads.v13.internal.bulk.RowValues;
import com.microsoft.bingads.v13.internal.bulk.SimpleBulkMapping;
import com.microsoft.bingads.v13.internal.bulk.StringExtensions;
import com.microsoft.bingads.v13.internal.bulk.StringTable;

/**
 * Represents a call ad extension. This class exposes {@link #setCallAdExtension} and {@link #getCallAdExtension}
 * that can be used to read and write fields of the Call Ad Extension record in a bulk file.
 *
 * For more information, see Call Ad Extension at
 * https://go.microsoft.com/fwlink/?linkid=846127
 *
 * @see BulkServiceManager
 * @see BulkOperation
 * @see BulkFileReader
 * @see BulkFileWriter
 */
public class BulkCallAdExtension extends BulkAdExtension {

    /**
     * Gets the call ad extension.
     */
    public CallAdExtension getCallAdExtension() {
        return this.getAdExtension();
    }

    /**
     * Sets the call ad extension.
     */
    public void setCallAdExtension(CallAdExtension value) {
        this.setAdExtension(value);
    }

    private static List> MAPPINGS;

    static {
        List> m = new ArrayList>();

        m.add(new SimpleBulkMapping(StringTable.PhoneNumber,
                new Function() {
                    @Override
                    public String apply(BulkCallAdExtension c) {
                        return c.getCallAdExtension().getPhoneNumber();
                    }
                },
                new BiConsumer() {
                    @Override
                    public void accept(String v, BulkCallAdExtension c) {
                        c.getCallAdExtension().setPhoneNumber(v);
                    }
                }
        ));

        m.add(new SimpleBulkMapping(StringTable.CountryCode,
                new Function() {
                    @Override
                    public String apply(BulkCallAdExtension c) {
                        return c.getCallAdExtension().getCountryCode();
                    }
                },
                new BiConsumer() {
                    @Override
                    public void accept(String v, BulkCallAdExtension c) {
                        c.getCallAdExtension().setCountryCode(v);
                    }
                }
        ));

        m.add(new SimpleBulkMapping(StringTable.IsCallOnly,
                new Function() {
                    @Override
                    public String apply(BulkCallAdExtension c) {
                        return StringExtensions.toBooleanBulkString(c.getCallAdExtension().getIsCallOnly());
                    }
                },
                new BiConsumer() {
                    @Override
                    public void accept(String v, BulkCallAdExtension c) {
                        c.getCallAdExtension().setIsCallOnly(StringExtensions.parseOptional(v, new Function() {
                            @Override
                            public Boolean apply(String value) {
                                return Boolean.parseBoolean(value);
                            }
                        }));
                    }
                }
        ));

        m.add(new SimpleBulkMapping(StringTable.IsCallTrackingEnabled,
                new Function() {
                    @Override
                    public String apply(BulkCallAdExtension c) {
                        return StringExtensions.toBooleanBulkString(c.getCallAdExtension().getIsCallTrackingEnabled());
                    }
                },
                new BiConsumer() {
                    @Override
                    public void accept(String v, BulkCallAdExtension c) {
                        c.getCallAdExtension().setIsCallTrackingEnabled(StringExtensions.parseOptional(v, new Function() {
                            @Override
                            public Boolean apply(String value) {
                                return Boolean.parseBoolean(value);
                            }
                        }));
                    }
                }
        ));

        m.add(new SimpleBulkMapping(StringTable.RequireTollFreeTrackingNumber,
                new Function() {
                    @Override
                    public String apply(BulkCallAdExtension c) {
                        return StringExtensions.toBooleanBulkString(c.getCallAdExtension().getRequireTollFreeTrackingNumber());
                    }
                },
                new BiConsumer() {
                    @Override
                    public void accept(String v, BulkCallAdExtension c) {
                        c.getCallAdExtension().setRequireTollFreeTrackingNumber(StringExtensions.parseOptional(v, new Function() {
                            @Override
                            public Boolean apply(String value) {
                                return Boolean.parseBoolean(value);
                            }
                        }));
                    }
                }
        ));

        MAPPINGS = Collections.unmodifiableList(m);
    }

    @Override
    public void processMappingsFromRowValues(RowValues values) {
        CallAdExtension extension = new CallAdExtension();
        extension.setType("CallAdExtension");
        this.setAdExtension(extension);

        super.processMappingsFromRowValues(values);

        MappingHelpers.convertToEntity(values, MAPPINGS, this);
    }

    @Override
    public void processMappingsToRowValues(RowValues values, boolean excludeReadonlyData) {
        this.validatePropertyNotNull(this.getCallAdExtension(), "CallAdExtension");

        super.processMappingsToRowValues(values, excludeReadonlyData);

        MappingHelpers.convertToValues(this, values, MAPPINGS);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy