package com.sharefaith.thesharefaithapp.models;

import com.appideas.base.AiSTr;
import com.sharefaith.thesharefaithapp.base.SFAppData;

import java.util.HashMap;

/**
 * Created by sfwebsitedev on 3/18/16.
 * model for Bible version
 */
public class SFBibleModel
{
    private SFAppData mAppdata = new SFAppData();
    /** Id of Bible version */
    public int mId;
    /** Abbreviation of Bible version */
    public String mAbreviation;
    /** Full name of Bible version */
    public String mFullName;
    /** Copyright string for Bible version */
    public String mCopyright;
    public int mSyncVersion;
    public String mLanguage;
    /** API provider for Bible version */
    public String mApiProvider;
    /** API key for Bible version */
    public String mApiKey;
    /** Path to Bible version if downloaded*/
    public String mPath;
    /** Is the Bible version downloaded*/
    public boolean mIsDownloaded;
    public int mAccessTime;
    /** Does this Bible version have audio */
    public boolean mHasAudio;

    public SFBibleModel(String versionAbrev)
    {
        mAbreviation = versionAbrev;
        if(mAbreviation.equals( "esv" ))
        {
            mHasAudio = true;
        }
        else
        {
            mHasAudio = false;
        }

        updateMembers();
    }

    public void updateMembers()
    {
        HashMap<String,String> bibleContent = new HashMap<String, String>(  );
        bibleContent = mAppdata.getBibleContent( mAbreviation );
        //Log.d( "mTag", "bibleContent id = " + bibleContent.get( "id" ) );
        this.mId = AiSTr.denullifyInt(  bibleContent.get( "id" ) );
        this.mFullName = bibleContent.get( "full_name" );
        this.mCopyright = bibleContent.get( "copyright" );
        this.mSyncVersion = AiSTr.denullifyInt(  bibleContent.get( "sync_version" ) );
        this.mLanguage = bibleContent.get( "language" );
        this.mApiProvider = bibleContent.get( "api_provider" );
        this.mApiKey = bibleContent.get( "api_key" );
        this.mPath = bibleContent.get( "path" );
        this.mIsDownloaded =  AiSTr.dbToBool( AiSTr.denullifyInt(  bibleContent.get( "is_downloaded" ) ) );
        this.mAccessTime = AiSTr.denullifyInt(  bibleContent.get( "access_time" ) );
    }

}
